Skip to content

Commit

Permalink
fix: execution contexts might be created before previous is destroyed (
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jun 26, 2024
1 parent 56d1d3f commit db642d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions packages/puppeteer-core/src/cdp/FrameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
}
if (contextPayload.auxData && contextPayload.auxData['isDefault']) {
world = frame.worlds[MAIN_WORLD];
} else if (
contextPayload.name === UTILITY_WORLD_NAME &&
!frame.worlds[PUPPETEER_WORLD].hasContext()
) {
} else if (contextPayload.name === UTILITY_WORLD_NAME) {
// In case of multiple sessions to the same target, there's a race between
// connections so we might end up creating multiple isolated worlds.
// We can use either.
Expand Down
4 changes: 3 additions & 1 deletion packages/puppeteer-core/src/cdp/IsolatedWorld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {TimeoutSettings} from '../common/TimeoutSettings.js';
import type {EvaluateFunc, HandleFor} from '../common/types.js';
import {
fromEmitterEvent,
timeout,
withSourcePuppeteerURLIfNone,
} from '../common/util.js';
import {disposeSymbol} from '../util/disposable.js';
Expand Down Expand Up @@ -143,7 +144,8 @@ export class IsolatedWorld extends Realm {
// The message has to match the CDP message expected by the WaitTask class.
throw new Error('Execution context was destroyed');
})
)
),
timeout(this.timeoutSettings.timeout())
)
)
);
Expand Down

0 comments on commit db642d1

Please sign in to comment.