You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Early boot without Range can wait for the whole download: progress is reported before its index is stored #144
What happens.pack.test.ts > "attaches the parts while a download from a host without Range is under way" failed in Firefox on main again, on 5d2f20d (the job), as in #75:
The rerun passed. #76 paced the test so a slow runner has two seconds to boot instead of half of one, but this failure does not depend on that window. It is an ordering race in the Jobs worker.
Why. On a host without Range, the Jobs worker indexes the archive as it downloads. Its onProgress sends the report first, and only then starts storing the snapshot of the entries found so far (jobs-worker.ts):
On each report, the element's tryBoot (downloadAndIndex) sends index to the Service Worker, which reads the snapshot with getForwardIndex() (mount.ts). When that read comes before setForwardIndex has stored the new snapshot, the worker sees the previous one, or none, and the frame cannot boot yet. Nothing asks again until the next report, one 256 kB chunk later.
The test's package is 265,685 bytes. Its first report, at 256 kB, is its last before the download ends, so a lost race there sends the load through indexing, as a whole download does.
Proof. With setForwardIndex delayed by 400 ms, the test failed on every run in Chromium, with the same extra indexing. With the report sent after the write, it passed under the same delay. The delay was a one-off edit, so the suite as it is catches the race only now and then.
Effect. On a host without Range, the frame can boot one chunk later than the index allows. For a package under 512 kB, whose first report is its last before the end, that means the whole download. On a slow link, one chunk can take seconds.
Proposed fix. Send the report once its snapshot is stored:
publishIndex serialises the writes and catches a refused one, so the report still goes out when the store refuses a snapshot, and the reports keep their order.
With nothing new to publish, it returns the chain as it stands, so the report waits only for writes already under way.
The last report still comes before done, which is sent after the final publish on the same chain.
Run the full browser suite in Chromium, Firefox and WebKit before merging.
Activity