Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Replay Bug]: 404 when first registering service worker #412

Open
sebastian-alvarez-RS opened this issue Mar 30, 2025 · 0 comments
Open
Labels
bug Something isn't working replay bug Archived content is not displaying as expected

Comments

@sebastian-alvarez-RS
Copy link

ReplayWeb.page Version

v2.0.0-2.3.4

What did you expect to happen? What happened instead?

When the service worker is registered for the first time in the browser there is a chance that the request to /replay/?source= is not intercepted in time which causes the 404 page from the website embedding replay to be iframed instead. Most of the times the 404 will only be seen momentarily and then it will try to reload (up to 2 times). However sometimes it will not reload (this happened mostly with Edge, not so much with Chrome), which forces the client to manually refresh.

Step-by-step reproduction instructions

  1. Go to https://webrecorder.github.io/web-replay-gen/archive/?source=s3://webrecorder-builds/warcs/netpreserve-twitter.warc
  2. Open browser dev-tools and clear all application storage data (make sure that unregister service workers is checked). Go to the network tab.
  3. Refresh the page.
  4. The site might return a 404 first and then load replay. Repeat the steps if not. With the demo website it didn’t happen too often but with a heavier project it happened every time.
Image Image Image Image

Additional details

Workaround: Looking at the response of that first request it looks like this:

    <!doctype html>
    <html>
    <head><script src="./ui.js"></script></head>
    <body>
    <replay-app-main></replay-app-main>
    </body></html>

So one way to avoid the 404 is to copy the above html and self-host it in /replay/index.html. Then on the web server make sure requests to /replay/ are rewritten to /replay/index.html. This way the first request will get the expected response if the service worker does not register and intercepts on time. Subsequent requests will be intercepted as expected. However this might not be a good long term solution if the contents of the above html change In a future version.

@sebastian-alvarez-RS sebastian-alvarez-RS added bug Something isn't working replay bug Archived content is not displaying as expected labels Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working replay bug Archived content is not displaying as expected
Projects
None yet
Development

No branches or pull requests

1 participant