mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: ignore not found contexts for console messages (#9595)
This commit is contained in:
parent
6f094d2f83
commit
390685bbe5
@ -174,12 +174,18 @@ export class FrameManager extends EventEmitter {
|
||||
contextId: number,
|
||||
session: CDPSession = this.#client
|
||||
): ExecutionContext {
|
||||
const key = `${session.id()}:${contextId}`;
|
||||
const context = this.#contextIdToContext.get(key);
|
||||
const context = this.getExecutionContextById(contextId, session);
|
||||
assert(context, 'INTERNAL ERROR: missing context with id = ' + contextId);
|
||||
return context;
|
||||
}
|
||||
|
||||
getExecutionContextById(
|
||||
contextId: number,
|
||||
session: CDPSession = this.#client
|
||||
): ExecutionContext | undefined {
|
||||
return this.#contextIdToContext.get(`${session.id()}:${contextId}`);
|
||||
}
|
||||
|
||||
page(): Page {
|
||||
return this.#page;
|
||||
}
|
||||
|
@ -747,10 +747,20 @@ export class CDPPage extends Page {
|
||||
// @see https://github.com/puppeteer/puppeteer/issues/3865
|
||||
return;
|
||||
}
|
||||
const context = this.#frameManager.executionContextById(
|
||||
const context = this.#frameManager.getExecutionContextById(
|
||||
event.executionContextId,
|
||||
this.#client
|
||||
);
|
||||
if (!context) {
|
||||
debugError(
|
||||
new Error(
|
||||
`ExecutionContext not found for a console message: ${JSON.stringify(
|
||||
event
|
||||
)}`
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
const values = event.args.map(arg => {
|
||||
return createJSHandle(context, arg);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user