Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix the Session with given id not found (closes #7865, #7810) #7875

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/native-automation/request-pipeline/safe-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import ErrorReason = Protocol.Network.ErrorReason;
import { isRequestPausedEvent } from '../utils/cdp';
import { ContinueRequestArgs, SessionId } from '../types';

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.
const IGNORED_ERROR_CODES = {
// 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.
INVALID_INTERCEPTION_ID: -32602,
// The "Session not found" error can occur in iframes for unclear reasons.
SESSION_WITH_GIVEN_ID_NOT_FOUND: -32001,
};

async function connectionResetGuard (handleRequestFn: () => Promise<void>, handleErrorFn: (err: any) => void): Promise<void> {
try {
await handleRequestFn();
}
catch (err: any) {
if (err.message === INVALID_INTERCEPTED_RESPONSE_ERROR_MSG)
if (Object.values(IGNORED_ERROR_CODES).includes(err?.response?.code))
return;

handleErrorFn(err);
Expand Down