From 46f9fa005e7b73fce235977c6a45c8b6fb1ec967 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 10 Mar 2023 14:54:32 -0800 Subject: [PATCH] fix(tracing): do not double-zip entries in remote mode (#21579) Fixes #21435. --- packages/playwright-core/src/client/tracing.ts | 4 ++-- .../playwright-core/src/server/trace/recorder/tracing.ts | 6 +++--- tests/library/trace-viewer.spec.ts | 2 -- utils/build/build.js | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.ts index 2a5507987a..231c5e8d3c 100644 --- a/packages/playwright-core/src/client/tracing.ts +++ b/packages/playwright-core/src/client/tracing.ts @@ -87,7 +87,7 @@ export class Tracing extends ChannelOwner implements ap await artifact.delete(); // Add local sources to the remote trace if necessary. - if (result.entries?.length) - await this._connection.localUtils()._channel.zip({ zipFile: filePath, entries: result.entries!, metadata, mode: 'append', includeSources: this._includeSources }); + if (metadata.length) + await this._connection.localUtils()._channel.zip({ zipFile: filePath, entries: [], metadata, mode: 'append', includeSources: this._includeSources }); } } diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.ts index 5d7195bb24..f4281378c7 100644 --- a/packages/playwright-core/src/server/trace/recorder/tracing.ts +++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts @@ -218,7 +218,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps await this._writeChain; } - async stopChunk(params: TracingTracingStopChunkParams): Promise<{ artifact?: Artifact, entries?: NameValue[], sourceEntries?: NameValue[] }> { + async stopChunk(params: TracingTracingStopChunkParams): Promise<{ artifact?: Artifact, entries?: NameValue[] }> { if (this._isStopping) throw new Error(`Tracing is already stopping`); this._isStopping = true; @@ -227,7 +227,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps this._isStopping = false; if (params.mode !== 'discard') throw new Error(`Must start tracing before stopping`); - return { sourceEntries: [] }; + return {}; } const state = this._state!; @@ -270,7 +270,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps if (params.mode === 'entries') return { entries }; const artifact = await this._exportZip(entries, state).catch(() => undefined); - return { artifact, entries }; + return { artifact }; }).finally(() => { // Only reset trace sha1s, network resources are preserved between chunks. state.traceSha1s = new Set(); diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index d75764c5b6..ff8b7123ee 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -25,8 +25,6 @@ const test = playwrightTest.extend(traceViewerFixtures); test.skip(({ trace }) => trace === 'on'); test.slow(); -test.fixme(({ mode }) => mode === 'service' || mode === 'driver', 'https://github.com/microsoft/playwright/issues/21435'); - let traceFile: string; test.beforeAll(async function recordTrace({ browser, browserName, browserType, server }, workerInfo) { diff --git a/utils/build/build.js b/utils/build/build.js index c2e5382014..b0079079f1 100644 --- a/utils/build/build.js +++ b/utils/build/build.js @@ -263,7 +263,7 @@ for (const bundle of bundles) { for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) { steps.push({ command: 'npx', - args: ['vite', 'build', ...(watchMode ? ['--watch', '--sourcemap'] : [])], + args: ['vite', 'build', ...(watchMode ? ['--watch', '--sourcemap', '--minify=false'] : [])], shell: true, cwd: path.join(__dirname, '..', '..', 'packages', webPackage), concurrent: true, @@ -272,7 +272,7 @@ for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) { // Build/watch trace viewer service worker. steps.push({ command: 'npx', - args: ['vite', '--config', 'vite.sw.config.ts', 'build', ...(watchMode ? ['--watch', '--sourcemap'] : [])], + args: ['vite', '--config', 'vite.sw.config.ts', 'build', ...(watchMode ? ['--watch', '--sourcemap', '--minify=false'] : [])], shell: true, cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'), concurrent: true,