-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proxyless: fix sporadic 'Invalid InterceptionId' error. (#7359)
- Loading branch information
1 parent
3351b62
commit 74ff543
Showing
8 changed files
with
102 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import CONTENT_TYPES from '../../assets/content-types'; | ||
|
||
const INVALID_INTERCEPTED_RESPONSE_ERROR_MSG = 'Invalid InterceptionId.'; | ||
|
||
const FAVICON_CONTENT_TYPE_HEADER = { | ||
name: 'content-type', | ||
value: CONTENT_TYPES.icon, | ||
}; | ||
|
||
export { | ||
INVALID_INTERCEPTED_RESPONSE_ERROR_MSG, | ||
FAVICON_CONTENT_TYPE_HEADER, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ProtocolApi } from 'chrome-remote-interface'; | ||
import { requestPipelineLogger } from '../../utils/debug-loggers'; | ||
import Protocol from 'devtools-protocol'; | ||
import RequestPausedEvent = Protocol.Fetch.RequestPausedEvent; | ||
import FulfillRequestRequest = Protocol.Fetch.FulfillRequestRequest; | ||
import ContinueResponseRequest = Protocol.Fetch.ContinueResponseRequest; | ||
import { isRequestPausedEvent } from '../utils/cdp'; | ||
|
||
const INVALID_INTERCEPTED_RESPONSE_ERROR_MSG = 'Invalid InterceptionId.'; | ||
|
||
// In some cases (a request was aborted, any page that initiated the request doesn't exist, etc.) | ||
// Chrome Debug Protocol doesn't allow to continue request pipeline | ||
// and raises the "Invalid InterceptionId" error. | ||
// We use the simplest way to fix it - omit such an error. | ||
|
||
export async function safeContinueResponse (client: ProtocolApi, data: RequestPausedEvent | ContinueResponseRequest): Promise<void> { | ||
const isPausedEvent = isRequestPausedEvent(data); | ||
|
||
try { | ||
const param = isPausedEvent | ||
? { requestId: data.requestId } | ||
: data; | ||
|
||
await client.Fetch.continueResponse(param); | ||
} | ||
catch (err: any) { | ||
if (err.message === INVALID_INTERCEPTED_RESPONSE_ERROR_MSG) | ||
return; | ||
|
||
const formatter = isPausedEvent ? '%r' : '%s'; | ||
|
||
requestPipelineLogger(`Fetch.continueResponse. Unhandled error %s during processing ${formatter}`, err, data); | ||
|
||
throw err; | ||
} | ||
} | ||
|
||
export async function safeFulfillRequest (client: ProtocolApi, fulfillInfo: FulfillRequestRequest): Promise<void> { | ||
try { | ||
await client.Fetch.fulfillRequest(fulfillInfo); | ||
} | ||
catch (err: any) { | ||
if (err.message === INVALID_INTERCEPTED_RESPONSE_ERROR_MSG) | ||
return; | ||
|
||
requestPipelineLogger(`Fetch.fulfillRequest. Unhandled error %s during processing %s`, err, fulfillInfo.requestId); | ||
|
||
throw err; | ||
} | ||
} | ||
|
||
export async function safeContinueRequest (client: ProtocolApi, event: RequestPausedEvent): Promise<void> { | ||
try { | ||
await client.Fetch.continueRequest({ requestId: event.requestId }); | ||
} | ||
catch (err: any) { | ||
if (err.message === INVALID_INTERCEPTED_RESPONSE_ERROR_MSG) | ||
return; | ||
|
||
requestPipelineLogger(`Fetch.continueRequest. Unhandled error %s during processing %r`, err, event); | ||
|
||
throw err; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters