Bug Description
In Playwright 1.58.0, the StdinServer._loadTrace() method in traceViewer.ts does not call validateTraceUrl() to convert file paths to the file?path= URI format. This causes the trace viewer to fail when receiving trace paths via stdin (used by VS Code extension for live trace).
Steps to Reproduce
- Install Playwright 1.58.0 or 1.58.1
- Use VS Code extension (v1.1.17) with "Show trace viewer" enabled
- Run a test
- Observe the trace viewer fails to load with error:
Not allowed to load local resource: file:///C:/Users/.../test-results/.playwright-artifacts-0/traces/xxx.json
Root Cause
In commit 185bfb7d4 ("fix(trace): operate trace uri, not path #38566"), the validateTraceUrl() function was updated to convert file paths to file?path= URI format. However, StdinServer._loadTrace() was not updated to use this function.
Current code (buggy):
private _loadTrace(traceUrl: string) {
this._traceUrl = traceUrl; // Raw file path sent to frontend
clearTimeout(this._pollTimer);
this.sendEvent?.('loadTraceRequested', { traceUrl });
}
Expected behavior:
The path should be converted using validateTraceUrl() before sending to frontend.
Affected Components
- VS Code extension live trace functionality
- Any client using
--stdin mode with show-trace
Workaround
Apply this patch to node_modules/playwright-core/lib/server/trace/viewer/traceViewer.js:
_loadTrace(traceUrl) {
- this._traceUrl = traceUrl;
+ const validatedUrl = validateTraceUrl(traceUrl);
+ this._traceUrl = validatedUrl;
clearTimeout(this._pollTimer);
- this.sendEvent?.("loadTraceRequested", { traceUrl });
+ this.sendEvent?.("loadTraceRequested", { traceUrl: validatedUrl });
}
For pnpm users, save this as patches/playwright-core@1.58.1.patch and add to package.json:
"pnpm": {
"patchedDependencies": {
"playwright-core@1.58.1": "patches/playwright-core@1.58.1.patch"
}
}
Environment
- Playwright version: 1.58.0, 1.58.1
- VS Code extension version: 1.1.17
- OS: Windows 11
- Node.js: 20.x
Related
Bug Description
In Playwright 1.58.0, the
StdinServer._loadTrace()method intraceViewer.tsdoes not callvalidateTraceUrl()to convert file paths to thefile?path=URI format. This causes the trace viewer to fail when receiving trace paths via stdin (used by VS Code extension for live trace).Steps to Reproduce
Root Cause
In commit
185bfb7d4("fix(trace): operate trace uri, not path #38566"), thevalidateTraceUrl()function was updated to convert file paths tofile?path=URI format. However,StdinServer._loadTrace()was not updated to use this function.Current code (buggy):
Expected behavior:
The path should be converted using
validateTraceUrl()before sending to frontend.Affected Components
--stdinmode withshow-traceWorkaround
Apply this patch to
node_modules/playwright-core/lib/server/trace/viewer/traceViewer.js:_loadTrace(traceUrl) { - this._traceUrl = traceUrl; + const validatedUrl = validateTraceUrl(traceUrl); + this._traceUrl = validatedUrl; clearTimeout(this._pollTimer); - this.sendEvent?.("loadTraceRequested", { traceUrl }); + this.sendEvent?.("loadTraceRequested", { traceUrl: validatedUrl }); }For pnpm users, save this as
patches/playwright-core@1.58.1.patchand add topackage.json:Environment
Related