Resolve pending callbacks when connection closes

This patch:
- resolves pending callbacks in connection once it gets closed
- fixes one of Page.screenshot() tests to wait for all the screenshots
- starts handling ECONNRESET error in test server to avoid throwing with no
  good reason
This commit is contained in:
Andrey Lushnikov
2017-07-19 00:40:52 -07:00
parent 40c66d1f2a
commit 2e94f9f67b
3 changed files with 10 additions and 2 deletions

View File

@@ -79,6 +79,12 @@ class SimpleServer {
_onSocket(socket) {
this._sockets.add(socket);
// ECONNRESET is a legit error given
// that tab closing simply kills process.
socket.on('error', error => {
if (error.code !== 'ECONNRESET')
throw error;
});
socket.once('close', () => this._sockets.delete(socket));
}