mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Never sent 'requestfinished' event without passing actual request
It turns out we're not receiving 'Network.requestWillBeSent' event for every requestId. This patch makes sure we don't dispatch `requestfinished` and `requestfailed` events without passing actual request. References #168
This commit is contained in:
parent
8e8517026f
commit
67f4264162
@ -114,6 +114,10 @@ class NetworkManager extends EventEmitter {
|
||||
*/
|
||||
_onLoadingFinished(event) {
|
||||
let request = this._idToRequest.get(event.requestId);
|
||||
// For certain requestIds we never receive requestWillBeSent event.
|
||||
// @see https://github.com/GoogleChrome/puppeteer/issues/168
|
||||
if (!request)
|
||||
return;
|
||||
this._idToRequest.delete(event.requestId);
|
||||
this.emit(NetworkManager.Events.RequestFinished, request);
|
||||
}
|
||||
@ -123,6 +127,10 @@ class NetworkManager extends EventEmitter {
|
||||
*/
|
||||
_onLoadingFailed(event) {
|
||||
let request = this._idToRequest.get(event.requestId);
|
||||
// For certain requestIds we never receive requestWillBeSent event.
|
||||
// @see https://github.com/GoogleChrome/puppeteer/issues/168
|
||||
if (!request)
|
||||
return;
|
||||
this._idToRequest.delete(event.requestId);
|
||||
this.emit(NetworkManager.Events.RequestFailed, request);
|
||||
}
|
||||
|
@ -457,6 +457,9 @@ describe('Puppeteer', function() {
|
||||
expect(error.message).toContain('Cannot navigate to invalid URL');
|
||||
}));
|
||||
it('should fail when navigating to bad SSL', SX(async function() {
|
||||
page.on('request', request => expect(request).toBeTruthy());
|
||||
page.on('requestfinished', request => expect(request).toBeTruthy());
|
||||
page.on('requestfailed', request => expect(request).toBeTruthy());
|
||||
let error = null;
|
||||
try {
|
||||
await page.navigate(HTTPS_PREFIX + '/empty.html');
|
||||
|
Loading…
Reference in New Issue
Block a user