Repository navigation
fix(onlion): only the big wasm is deferred; callbacks.wasm stays a module - #138
Merged
Merged
Conversation
…dule f86d384 shipped a defect: the inline-wasm plugin matched every *.wasm, so callbacks.wasm became a factory function too. The generated loader imports it as a real WebAssembly.Module and does `new WebAssembly.Instance(callbacksModule, ...)`, which threw "Argument 0 must be a WebAssembly.Module" inside runSQLite3PostLoadInit - every /search that needed SQLite answered 503 in 75-150 ms, while /add kept succeeding (the accept never touches SQLite). callbacks.wasm (19 KB) is back to an eager module; sqlite3.wasm (the 1.5 MB one, the actual cold-start cost) stays behind the lazy factory. Caught on the deployed endpoint, not by the suite: Miniflare exercises the wrangler build, which never runs this plugin. `npm run test:edgeone` does drive the built bundle and does load SQLite, so it covers this class.
…ead, and stops retrying OPFS Two behaviour-preserving transforms, both measured: 1. search loaded SQLite before reading anything (worker.mjs, `sqliteReady()` in search). A user whose writes are still in the log has no partitions at all - the harness's first questions are exactly that - so the module was decoded and compiled for nothing. `readSearchCandidates` now takes a memoised `getSqlite` and resolves it inside the partition loop. Verified: a search on an unknown user returns 200 in 19 ms with `sqlite_loaded: false`. 2. every SQLite load tried to install the OPFS VFS twice and threw twice (no `location` in this runtime), printing two stack traces per cold start. The loader gates those installers on `config.disable.vfs`, whose source is `globalThis.sqlite3ApiConfig` (worker-loader.mjs 3064, gates at 15699 and 16964) - not init()'s argument, which is why passing it there changed nothing. Verified: the two stacks per load went from 2 to 0 in a full verify run (22 occurrences before, 0 after). Full suite 37 PASS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Doc owner:
docs/decisions/implemented/2026-10-30-defer-wasm-load.{md,zh-CN.md}(corrected in this PR).Live defect from f86d384, caught on the deployed endpoint: the inline-wasm plugin matched every
*.wasm, socallbacks.wasmalso became a factory. The generated loader imports it as a realWebAssembly.Module, sonew WebAssembly.Instance(callbacksModule, ...)threwArgument 0 must be a WebAssembly.ModuleinsiderunSQLite3PostLoadInit— every/searchthat needed SQLite answered 503 in 75-150 ms, while/addkept succeeding because the accept never touches SQLite.Fix:
callbacks.wasm(19 KB) stays eager;sqlite3.wasm(1.5 MB, the actual cold-start cost) stays lazy.Not verified
The suite did not catch it: Miniflare runs the wrangler build, which never executes this plugin.
npm run test:edgeonedrives the built bundle with a real COS bucket and does load SQLite, so it covers this class — it reports 13/14 with a/capacityexpectation that predates the log-mode default (a fresh user has no manifest until a fold), which is a separate test defect.