Repository navigation
Handle ready() without /index.html, as in the README examples #70
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
- Goal: A
ready()without/index.html, as in the README examples, behaves the same in both Workers and as documented. - Current gap: The Web Worker writes a default
/index.htmlduring setup, but the Service Worker never gets one. The Service Worker serves the preview HTML from its own virtual filesystem, so aready()without/index.htmlleaves the preview without HTML. The Web Worker's default is never served. - Effect:
- The README usage example passes only
/main.js, which writes into#app. It relies on anindex.htmlwith#appthat loads/main.js, which is what the Web Worker's default contains. Following the example shows no preview. The example in theready()section passes no/index.htmleither. - Since fix(vite-dev-server): answer missing files within the preview base path with 404 #69, the preview reports one
previewLoadErrorwith status 404 and stays blank. Before fix(vite-dev-server): answer missing files within the preview base path with 404 #69, the 404 was fetched again from the host, and with@vrowzer/vite-pluginthe preview reloaded every second. - The virtual filesystems of the two Workers differ in
/index.html.
- The README usage example passes only
- Request: Decide whether a default
index.htmlis part of the API. Then make both Workers and the README agree (see the options in Details). - Verification status: Reproduced in the browser by deleting
/index.htmlin the vrowzer integration playground (see Details). The README example itself was not run. - Related: Found while working on Return 404 for missing preview files instead of fetching them from the host #68.
Details
Current implementation, verification, options, and acceptance criteria
Current implementation
Reviewed at cdac4cd.
- The README usage example and the example in the
ready()section pass no/index.html. - The Web Worker's
setupVirtualFiles()writes a default/index.htmlwith<div id="app"><p>Loading...</p></div>and<script type="module" src="/main.js"></script>, then writes the files given toready(). It was added in 72ee3f0, a WIP commit with no stated reason. - The Service Worker's
initServiceWorker()writes only the client files and/public/.gitkeep. The files given toready()arrive later inV_FS_INIT(index.ts). No default/index.htmlreaches it. - The Service Worker serves the preview HTML from its own virtual filesystem.
indexHtmlMiddlewaremoves on when the file is missing, andnotFoundMiddlewareanswers with 404. - Every test fixture passes
/index.html: the integration fixtures (playground, custom-base, dispose) explicitly, and the e2e fixtures through the vite-plugin manifest or explicitly. No test runsready()without/index.html. The test added in #69 reproduces a missing preview HTML by loading/favicon.icoinstead.
Verification
I ran temporary tests in packages/vrowzer/integration/vrowzer.integration-test.ts against the integration playground, in Playwright's Chromium. The tests deleted /index.html with deleteFile(), then mounted a new preview session. This leaves the Service Worker in the same state as a ready() without /index.html. The tests were not committed.
- At cdac4cd (with fix(vite-dev-server): answer missing files within the preview base path with 404 #69): the session reported one
previewLoadErrorwithstage: 'html',status: 404and the messageFailed to load the preview HTML: 404, and its body stayed empty. Nothing more was reported within 4.5 seconds. - At fce16a3 (before fix(vite-dev-server): answer missing files within the preview base path with 404 #69): the preview HTML request got the 503 "Waiting for Service Worker..." page of
@vrowzer/vite-plugin. Within 4.5 seconds, the iframe loaded 5 times and reported 5previewLoadErrorevents.
Options
- A. Give the Service Worker the same default.
- In
initialize(), add the default/index.htmlto the files sent to both Workers whenready()has none. The default then lives in one place. - Or write the same default in
service-worker-core.tstoo. The default then lives in two places.
- In
- B. Require
/index.html.- Remove the Web Worker's default, and add
/index.htmlto the README examples. - Make
ready()warn, or fail, without/index.html.
- Remove the Web Worker's default, and add
- C. Only add
/index.htmlto the README examples, and keep the Web Worker's default as it is.
The choice depends on whether a default index.html is part of the API. The README examples are currently written as if it were.
Acceptance criteria
- Both Workers agree on
/index.htmlwhenready()gets none: both have the same default, or neither has one. - The README examples work as written.
- The behavior without
/index.htmlis documented: a default page is shown, or the missing file is reported clearly. - A browser test covers
ready()without/index.html.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity