Skip to content

chore: add trace viewer file upload error handling#10243

Merged
mxschmitt merged 2 commits into
microsoft:masterfrom
mxschmitt:feature/trace-viewer-error-handling
Nov 11, 2021
Merged

chore: add trace viewer file upload error handling#10243
mxschmitt merged 2 commits into
microsoft:masterfrom
mxschmitt:feature/trace-viewer-error-handling

Conversation

@mxschmitt
Copy link
Copy Markdown
Contributor

@mxschmitt mxschmitt commented Nov 11, 2021

This fixes: npx playwright show-trace non-existing.zip

Fixes #10127

@pavelfeldman
Copy link
Copy Markdown
Member

Looks like #10127 can have a simpler fix. What exact scenario are we fixing here?

@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch 2 times, most recently from 370c7e0 to c09143f Compare November 11, 2021 19:12
Comment thread packages/playwright-core/src/web/traceViewer/ui/snapshotTab.tsx
try {
await traceModel.load(url, progress);
} catch (error) {
if (fetchFromInbuiltTraceViewerServer && error instanceof Error && error.message === 'HTTP error Not Found')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since local file URLs also get loaded over HTTP, check if its done via the internal trace viewer web-server and rewrite it that the local file could not be found (instead of showing the http error).

@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch from c09143f to 31cb34f Compare November 11, 2021 19:17
Comment thread packages/playwright-core/src/web/traceViewer/traceModel.ts Outdated
Comment thread packages/playwright-core/src/web/traceViewer/sw.ts Outdated
Comment thread packages/playwright-core/src/web/traceViewer/traceModel.ts Outdated
Comment thread packages/playwright-core/src/web/traceViewer/ui/workbench.tsx
Comment thread packages/playwright-core/src/web/traceViewer/ui/snapshotTab.tsx
Comment thread packages/playwright-core/src/web/traceViewer/sw.ts
// Don't re-use blob file URLs on page load (results in Fetch error)
if (newTraceURL && !newTraceURL.startsWith('blob:'))
setTraceURL(newTraceURL);
}, [setTraceURL]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean useEffect around setTraceURL, wouldn't it run only once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as the comment says its about if you open trace viewer with a blob URL. Usually old tab, forced reload etc.

@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch from 31cb34f to f7f122e Compare November 11, 2021 19:36
@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch from f7f122e to eea5888 Compare November 11, 2021 19:57
@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch from 5eb02a6 to bd7bc47 Compare November 11, 2021 20:30
@mxschmitt mxschmitt force-pushed the feature/trace-viewer-error-handling branch from bd7bc47 to 37f9ccc Compare November 11, 2021 20:31
@mxschmitt mxschmitt merged commit 8fe3ea7 into microsoft:master Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trace viewer should print error when the npx playwright show-trace foo.zip does not exist

2 participants