fix(trace): replay sub-resources from archive in trace snapshot CLI#40632
Open
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(trace): replay sub-resources from archive in trace snapshot CLI#40632Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Conversation
The trace snapshot CLI (and `trace serve`) only served the recorded HTML; sub-resources like stylesheets, images, and fonts were fetched live from the original origin, which meant snapshots would render without styles whenever the origin was unreachable. Serve sub-resources from the trace archive via a small service worker registered on a bootstrap page. The service worker forwards cross-origin requests to a `/__pwsnapshot/resource` endpoint on the CLI HTTP server, which delegates to `SnapshotServer.serveResource`. Same code path works for both `trace snapshot` and `trace serve`.
92381c0 to
dd738c6
Compare
dgozman
reviewed
May 5, 2026
| response.statusCode = 200; | ||
| response.setHeader('Content-Type', 'application/javascript'); | ||
| response.setHeader('Service-Worker-Allowed', '/'); | ||
| response.end(` |
Collaborator
There was a problem hiding this comment.
Can we extract this from a string literal? I find things like this hard to maintain.
This comment has been minimized.
This comment has been minimized.
Contributor
Test results for "MCP"1 failed 6906 passed, 1062 skipped Merge workflow run. |
pavelfeldman
reviewed
May 5, 2026
Member
pavelfeldman
left a comment
There was a problem hiding this comment.
Not sure I like the code fork, why doesn't it work out of the box?
Member
Author
|
Subresource URLs are not rewritten, so they to whatever was the original host. In trace viewer, we also use a service worker to catch them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trace snapshotCLI (andtrace serve) only replayed the recorded HTML; sub-resources fetched live from the original origin, so snapshots rendered unstyled whenever that origin was unreachable./__pwsnapshot/resourceendpoint that delegates toSnapshotServer.serveResource. Same path works for bothtrace snapshotandtrace serve.