refactor: remove unused promise (#7830)

This commit is contained in:
Ben Allfree 2021-12-09 06:35:23 -08:00 committed by GitHub
parent c03429444d
commit 71cc1b9591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 21 deletions

View File

@ -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;
}; };

View File

@ -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;
} }