Skip to content

Commit db642d1

Browse files
authored
fix: execution contexts might be created before previous is destroyed (#12666)
1 parent 56d1d3f commit db642d1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/puppeteer-core/src/cdp/FrameManager.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
454454
}
455455
if (contextPayload.auxData && contextPayload.auxData['isDefault']) {
456456
world = frame.worlds[MAIN_WORLD];
457-
} else if (
458-
contextPayload.name === UTILITY_WORLD_NAME &&
459-
!frame.worlds[PUPPETEER_WORLD].hasContext()
460-
) {
457+
} else if (contextPayload.name === UTILITY_WORLD_NAME) {
461458
// In case of multiple sessions to the same target, there's a race between
462459
// connections so we might end up creating multiple isolated worlds.
463460
// We can use either.

packages/puppeteer-core/src/cdp/IsolatedWorld.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {TimeoutSettings} from '../common/TimeoutSettings.js';
1616
import type {EvaluateFunc, HandleFor} from '../common/types.js';
1717
import {
1818
fromEmitterEvent,
19+
timeout,
1920
withSourcePuppeteerURLIfNone,
2021
} from '../common/util.js';
2122
import {disposeSymbol} from '../util/disposable.js';
@@ -143,7 +144,8 @@ export class IsolatedWorld extends Realm {
143144
// The message has to match the CDP message expected by the WaitTask class.
144145
throw new Error('Execution context was destroyed');
145146
})
146-
)
147+
),
148+
timeout(this.timeoutSettings.timeout())
147149
)
148150
)
149151
);

0 commit comments

Comments
 (0)