Skip to content

Commit

Permalink
fix: don't hold in memory finished requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Jul 18, 2023
1 parent 95e7557 commit cd70fd8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/bidiMapper/domains/network/networkProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,29 @@ export class NetworkProcessor {
}
);

cdpClient.on(
'Network.requestServedFromCache',
(params: Protocol.Network.RequestServedFromCacheEvent) => {
networkProcessor
.#getOrCreateNetworkRequest(params.requestId)
.onServedFromCache();
}
);

cdpClient.on(
'Network.loadingFailed',
(params: Protocol.Network.LoadingFailedEvent) => {
networkProcessor
.#getOrCreateNetworkRequest(params.requestId)
.onLoadingFailedEvent(params);
networkProcessor.#forgetRequest(params.requestId);
}
);

cdpClient.on(
'Network.requestServedFromCache',
'Network.loadingFinished',
(params: Protocol.Network.RequestServedFromCacheEvent) => {
networkProcessor
.#getOrCreateNetworkRequest(params.requestId)
.onServedFromCache();
networkProcessor.#forgetRequest(params.requestId);
}
);

Expand All @@ -125,6 +133,10 @@ export class NetworkProcessor {
return this.#requestMap.get(requestId);
}

#forgetRequest(requestId: Network.Request): void {
this.#requestMap.delete(requestId);
}

dispose() {
for (const request of this.#requestMap.values()) {
request.dispose();
Expand Down

0 comments on commit cd70fd8

Please sign in to comment.