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,
|
contextId: number,
|
||||||
session: CDPSession = this.#client
|
session: CDPSession = this.#client
|
||||||
): ExecutionContext {
|
): ExecutionContext {
|
||||||
const key = `${session.id()}:${contextId}`;
|
const context = this.getExecutionContextById(contextId, session);
|
||||||
const context = this.#contextIdToContext.get(key);
|
|
||||||
assert(context, 'INTERNAL ERROR: missing context with id = ' + contextId);
|
assert(context, 'INTERNAL ERROR: missing context with id = ' + contextId);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getExecutionContextById(
|
||||||
|
contextId: number,
|
||||||
|
session: CDPSession = this.#client
|
||||||
|
): ExecutionContext | undefined {
|
||||||
|
return this.#contextIdToContext.get(`${session.id()}:${contextId}`);
|
||||||
|
}
|
||||||
|
|
||||||
page(): Page {
|
page(): Page {
|
||||||
return this.#page;
|
return this.#page;
|
||||||
}
|
}
|
||||||
|
@ -747,10 +747,20 @@ export class CDPPage extends Page {
|
|||||||
// @see https://github.com/puppeteer/puppeteer/issues/3865
|
// @see https://github.com/puppeteer/puppeteer/issues/3865
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const context = this.#frameManager.executionContextById(
|
const context = this.#frameManager.getExecutionContextById(
|
||||||
event.executionContextId,
|
event.executionContextId,
|
||||||
this.#client
|
this.#client
|
||||||
);
|
);
|
||||||
|
if (!context) {
|
||||||
|
debugError(
|
||||||
|
new Error(
|
||||||
|
`ExecutionContext not found for a console message: ${JSON.stringify(
|
||||||
|
event
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const values = event.args.map(arg => {
|
const values = event.args.map(arg => {
|
||||||
return createJSHandle(context, arg);
|
return createJSHandle(context, arg);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user