Skip to content

Commit 311e592

Browse files
committed
chore: include target ID in UncaughtError
1 parent 67d4b7a commit 311e592

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/PageCollector.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ import {
2525
export class UncaughtError {
2626
readonly message: string;
2727
readonly stackTrace?: Protocol.Runtime.StackTrace;
28+
readonly targetId: string;
2829

29-
constructor(message: string, stackTrace?: Protocol.Runtime.StackTrace) {
30+
constructor(
31+
message: string,
32+
stackTrace: Protocol.Runtime.StackTrace | undefined,
33+
targetId: string,
34+
) {
3035
this.message = message;
3136
this.stackTrace = stackTrace;
37+
this.targetId = targetId;
3238
}
3339
}
3440

@@ -323,7 +329,11 @@ class PageIssueSubscriber {
323329
const messageWithRest = exception?.description?.split('\n at ', 2) ?? [];
324330
const message = text + ' ' + (messageWithRest[0] ?? '');
325331

326-
this.#page.emit('uncaughtError', new UncaughtError(message, stackTrace));
332+
this.#page.emit(
333+
'uncaughtError',
334+
// @ts-expect-error Use internal Puppeteer API for target ID
335+
new UncaughtError(message, stackTrace, this.#session.target()._targetId),
336+
);
327337
};
328338

329339
// On navigation, we reset issue aggregation.

0 commit comments

Comments
 (0)