Skip to content

Commit

Permalink
fix(tracing): support old traces with consoleMessage.args (#27095)
Browse files Browse the repository at this point in the history
Fixes #27072.
  • Loading branch information
dgozman authored Sep 15, 2023
1 parent b3edf8e commit a26f568
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
onEvent(sdkObject: SdkObject, event: trace.EventTraceEvent) {
if (!sdkObject.attribution.context)
return;
if (event.method === 'console' || (event.method === '__create__' && event.class === 'ConsoleMessage')) {
if (event.method === 'console' ||
(event.method === '__create__' && event.class === 'ConsoleMessage') ||
(event.method === '__create__' && event.class === 'JSHandle')) {
// Console messages are handled separately.
return;
}
Expand Down
15 changes: 14 additions & 1 deletion packages/trace-viewer/src/traceModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class TraceModel {
private _backend!: TraceModelBackend;
private _attachments = new Map<string, trace.AfterActionTraceEventAttachment>();
private _resourceToContentType = new Map<string, string>();
private _jsHandles = new Map<string, { preview: string }>();

constructor() {
}
Expand Down Expand Up @@ -112,6 +113,7 @@ export class TraceModel {
}

this._snapshotStorage!.finalize();
this._jsHandles.clear();
}

async hasEntry(filename: string): Promise<boolean> {
Expand Down Expand Up @@ -297,12 +299,23 @@ export class TraceModel {
return null;

if (event.type === 'event') {
if (metadata.method === '__create__' && metadata.type === 'JSHandle')
this._jsHandles.set(metadata.params.guid, metadata.params.initializer);
if (metadata.method === '__create__' && metadata.type === 'ConsoleMessage') {
return {
type: 'object',
class: metadata.type,
guid: metadata.params.guid,
initializer: metadata.params.initializer,
initializer: {
...metadata.params.initializer,
args: metadata.params.initializer.args?.map((arg: any) => {
if (arg.guid) {
const handle = this._jsHandles.get(arg.guid);
return { preview: handle?.preview || '', value: '' };
}
return { preview: '', value: '' };
})
},
};
}
return {
Expand Down

0 comments on commit a26f568

Please sign in to comment.