Skip to content

fix(trace): replay sub-resources from archive in trace snapshot CLI#40632

Open
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:fix-trace-snapshot-subresources
Open

fix(trace): replay sub-resources from archive in trace snapshot CLI#40632
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:fix-trace-snapshot-subresources

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented May 5, 2026

Summary

  • The trace snapshot CLI (and trace serve) only replayed the recorded HTML; sub-resources fetched live from the original origin, so snapshots rendered unstyled whenever that origin was unreachable.
  • Serve sub-resources from the trace archive via a small inline service worker on a bootstrap page. Cross-origin fetches forward to a /__pwsnapshot/resource endpoint that delegates to SnapshotServer.serveResource. Same path works for both trace snapshot and trace serve.

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`.
@Skn0tt Skn0tt force-pushed the fix-trace-snapshot-subresources branch from 92381c0 to dd738c6 Compare May 5, 2026 11:26
@Skn0tt Skn0tt requested a review from dgozman May 5, 2026 11:43
response.statusCode = 200;
response.setHeader('Content-Type', 'application/javascript');
response.setHeader('Service-Worker-Allowed', '/');
response.end(`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we extract this from a string literal? I find things like this hard to maintain.

@github-actions

This comment has been minimized.

@Skn0tt Skn0tt requested a review from dgozman May 5, 2026 12:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Test results for "MCP"

1 failed
❌ [webkit] › mcp/dashboard.spec.ts:207 › should enter annotate mode on fresh dashboard.tsx mount with -s --annotate @mcp-windows-latest-webkit

6906 passed, 1062 skipped


Merge workflow run.

Copy link
Copy Markdown
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

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

Not sure I like the code fork, why doesn't it work out of the box?

@Skn0tt
Copy link
Copy Markdown
Member Author

Skn0tt commented May 5, 2026

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.

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.

3 participants