leadfoot icon indicating copy to clipboard operation
leadfoot copied to clipboard

Leadfoot prevents process from exiting

Open rogierschouten opened this issue 7 years ago • 0 comments

When the Server#createSession() method fails due to a timeout error (selenium hub server not responding), leadfoot does not dispose something and hence the mocha process does not exit.

Reproduce:

  1. create a http server that listens for connections but does not respond to requests
  2. create a session and connect to that http server

code for http server (server.js):

var http = require("http");

var server = http.createServer(() => undefined);
server.listen(4444);

code for leadfoot test (test.js):

var leadfoot = require("@theintern/leadfoot");

describe("foo", function() {
	this.timeout(10E3);

	it("should dispose normally if the hub is not present", async () => {
		var host = "localhost";
		var port = 4444;
		var server = new leadfoot.Server(`http://${host}:${port}/wd/hub`, { timeout: 3000 });
		try {
			await server.createSession({ browserName: "chrome" });
		} catch (error) {
                        // try to dispose anything we can get our hands on
			const sessions = await server.getSessions();
			await Promise.all(sessions.map(async (s) => {
				await s.quit();
				await server.deleteSession(s.sessionId);
			}));
		}
	});
})

Now, run both node server.js and mocha test.js. The test process hangs indefinitely.

rogierschouten avatar Jun 28 '18 14:06 rogierschouten