mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
40c66d1f2a
commit
2e94f9f67b
@ -76,6 +76,8 @@ class Connection extends EventEmitter {
|
||||
_onClose() {
|
||||
this._ws.removeAllListeners();
|
||||
this._ws.close();
|
||||
for (let callback of this._callbacks.values())
|
||||
callback.reject(new Error(`Protocol error (${callback.method}): Target closed.`));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -628,8 +628,8 @@ describe('Puppeteer', function() {
|
||||
}
|
||||
}));
|
||||
}
|
||||
let screenshot = await promises[1];
|
||||
expect(screenshot).toBeGolden('screenshot-parallel-calls.png');
|
||||
let screenshots = await Promise.all(promises);
|
||||
expect(screenshots[1]).toBeGolden('screenshot-parallel-calls.png');
|
||||
}));
|
||||
it('should take fullPage screenshots', SX(async function() {
|
||||
await page.setViewport({width: 500, height: 500});
|
||||
|
Loading…
Reference in New Issue
Block a user