mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
refactor: remove unused promise (#7830)
This commit is contained in:
parent
c03429444d
commit
71cc1b9591
@ -3,8 +3,6 @@ import { HTTPRequest } from './HTTPRequest.js';
|
|||||||
|
|
||||||
export type QueuedEventGroup = {
|
export type QueuedEventGroup = {
|
||||||
responseReceivedEvent: Protocol.Network.ResponseReceivedEvent;
|
responseReceivedEvent: Protocol.Network.ResponseReceivedEvent;
|
||||||
promise: Promise<void>;
|
|
||||||
resolver: () => void;
|
|
||||||
loadingFinishedEvent?: Protocol.Network.LoadingFinishedEvent;
|
loadingFinishedEvent?: Protocol.Network.LoadingFinishedEvent;
|
||||||
loadingFailedEvent?: Protocol.Network.LoadingFailedEvent;
|
loadingFailedEvent?: Protocol.Network.LoadingFailedEvent;
|
||||||
};
|
};
|
||||||
|
@ -22,11 +22,7 @@ import { helper, debugError } from './helper.js';
|
|||||||
import { Protocol } from 'devtools-protocol';
|
import { Protocol } from 'devtools-protocol';
|
||||||
import { HTTPRequest } from './HTTPRequest.js';
|
import { HTTPRequest } from './HTTPRequest.js';
|
||||||
import { HTTPResponse } from './HTTPResponse.js';
|
import { HTTPResponse } from './HTTPResponse.js';
|
||||||
import {
|
import { FetchRequestId, NetworkEventManager } from './NetworkEventManager.js';
|
||||||
FetchRequestId,
|
|
||||||
NetworkEventManager,
|
|
||||||
NetworkRequestId,
|
|
||||||
} from './NetworkEventManager.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
@ -480,12 +476,8 @@ export class NetworkManager extends EventEmitter {
|
|||||||
.shift();
|
.shift();
|
||||||
if (!extraInfo) {
|
if (!extraInfo) {
|
||||||
// Wait until we get the corresponding ExtraInfo event.
|
// Wait until we get the corresponding ExtraInfo event.
|
||||||
let resolver = null;
|
|
||||||
const promise = new Promise<void>((resolve) => (resolver = resolve));
|
|
||||||
this._networkEventManager.queueEventGroup(event.requestId, {
|
this._networkEventManager.queueEventGroup(event.requestId, {
|
||||||
responseReceivedEvent: event,
|
responseReceivedEvent: event,
|
||||||
promise,
|
|
||||||
resolver,
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -493,15 +485,6 @@ export class NetworkManager extends EventEmitter {
|
|||||||
this._emitResponseEvent(event, extraInfo);
|
this._emitResponseEvent(event, extraInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseWaitingForExtraInfoPromise(
|
|
||||||
networkRequestId: NetworkRequestId
|
|
||||||
): Promise<void> {
|
|
||||||
const responseReceived =
|
|
||||||
this._networkEventManager.getQueuedEventGroup(networkRequestId);
|
|
||||||
if (!responseReceived) return Promise.resolve();
|
|
||||||
return responseReceived.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
_onResponseReceivedExtraInfo(
|
_onResponseReceivedExtraInfo(
|
||||||
event: Protocol.Network.ResponseReceivedExtraInfoEvent
|
event: Protocol.Network.ResponseReceivedExtraInfoEvent
|
||||||
): void {
|
): void {
|
||||||
@ -530,7 +513,6 @@ export class NetworkManager extends EventEmitter {
|
|||||||
if (queuedEvents.loadingFailedEvent) {
|
if (queuedEvents.loadingFailedEvent) {
|
||||||
this._emitLoadingFailed(queuedEvents.loadingFailedEvent);
|
this._emitLoadingFailed(queuedEvents.loadingFailedEvent);
|
||||||
}
|
}
|
||||||
queuedEvents.resolver();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user