[refactor] fetch-wasm.js checksum#1084
Conversation
- fetch WASM checksum, if ok skip full download - improved checksum verification, checks both checksum file list against expected file list, and expected files against checksum list
accius
left a comment
There was a problem hiding this comment.
The checksum-first skip is a good optimization: builds with a current bundle now download a few hundred bytes instead of the full wasm every time, and the two-way verification (expected files present in the checksum list AND every listed file hashing clean) closes the gap where a truncated sha256 file would pass silently. The response.resume() on redirects is a nice catch too, that was leaking sockets on every GitHub release redirect.
Fail-open semantics are preserved (any throw lands in warn() which exits 0 so builds never break on network trouble), which was the property I cared most about from the original review. Approving with two non-blocking nits if you feel like a follow-up:
- The mismatch error message interpolates the outer filename const, which is always 'p533.sha256', so a hash failure on p533.wasm reports the wrong file. Capturing which file failed inside verifyChecksum would make that diagnostic honest.
- fs.rmSync deletes the existing checksum file before the new download is known to succeed. Offline builds still ship the existing wasm (good), but they lose the checksum file, so every later build does a full re-download until the network is back. Downloading to a temp name and renaming on success would keep the fast path intact.
K0CJH
|
follow up changes made in #1089 |
What does this PR do?
scripts\fetch-wasm.jsType of change
How to test
npm run prebuildChecklist
server.js: caches have TTLs and size caps (we serve 2,000+ concurrent users)var(--accent-cyan), etc.).bak,.old,console.logdebug lines, or test scripts included