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 1 commit
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
9 changes: 8 additions & 1 deletion src/native-automation/request-pipeline/safe-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@ import ErrorReason = Protocol.Network.ErrorReason;
import { isRequestPausedEvent } from '../utils/cdp';
import { ContinueRequestArgs, SessionId } from '../types';

const INVALID_INTERCEPTED_RESPONSE_ERROR_MSG = 'Invalid InterceptionId.';
const INVALID_INTERCEPTED_RESPONSE_ERROR_MSG = 'Invalid InterceptionId.';
const SESSION_WITH_GIVEN_ID_NOT_FOUND_ERROR_MSG = 'Session with given id not found.';

// 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.

// The "Session not found" error can occur in iframes for unclear reasons.
// We choose to ignore this type of error as well.

async function connectionResetGuard (handleRequestFn: () => Promise<void>, handleErrorFn: (err: any) => void): Promise<void> {
try {
await handleRequestFn();
}
catch (err: any) {
if (err.message === SESSION_WITH_GIVEN_ID_NOT_FOUND_ERROR_MSG)
return;

if (err.message === INVALID_INTERCEPTED_RESPONSE_ERROR_MSG)
return;

Expand Down