Skip to content
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
9 changes: 6 additions & 3 deletions packages/playwright-core/src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { SdkObject } from './instrumentation';
import * as js from './javascript';
import * as network from './network';
import { Page, ariaSnapshotForFrame } from './page';
import { isAbortError, nullProgress, ProgressController } from './progress';
import { isAbortError, nullProgress, ProgressController, raceUncancellableOperationWithCleanup } from './progress';
import * as types from './types';
import { isSessionClosedError } from './protocolError';

Expand Down Expand Up @@ -1632,7 +1632,7 @@ export class Frame extends SdkObject<FrameEventMap> {
return this.retryWithProgressAndTimeouts(progress, [100], async () => {
const context = world === 'main' ? await progress.race(this.mainContext()) : await progress.race(this.utilityContext());
const injectedScript = await progress.race(context.injectedScript());
const handle = await progress.race(injectedScript.evaluateHandle((injected, { expression, isFunction, polling, arg }) => {
const handle = await raceUncancellableOperationWithCleanup(progress, () => injectedScript.evaluateHandle((injected, { expression, isFunction, polling, arg }) => {
let evaledExpression: any;
const predicate = (): R => {
// NOTE: make sure to use `globalThis.eval` instead of `self.eval` due to a bug with sandbox isolation
Expand Down Expand Up @@ -1679,7 +1679,10 @@ export class Frame extends SdkObject<FrameEventMap> {

next();
return { result, abort: () => aborted = true };
}, { expression, isFunction, polling: options.pollingInterval, arg }));
}, { expression, isFunction, polling: options.pollingInterval, arg }), async handle => {
await handle.evaluate(h => h.abort()).catch(() => {});
handle.dispose();
});
try {
return await progress.race(handle.evaluateHandle(h => h.result));
} catch (error) {
Expand Down
Loading