Replace @tootallnate/quickjs-emscripten with quickjs-wasi#394
Replace @tootallnate/quickjs-emscripten with quickjs-wasi#394TooTallNate merged 3 commits intomainfrom
@tootallnate/quickjs-emscripten with quickjs-wasi#394Conversation
🦋 Changeset detectedLatest commit: e053c6e The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the PAC-related packages off @tootallnate/quickjs-emscripten and onto quickjs-wasi, updating the VM construction/usage and aligning tests with quickjs-ng error formatting.
Changes:
- Swapped QuickJS implementation to
quickjs-wasiand updated call sites to useQuickJS.create()and the new promise/job APIs. - Updated
degenerator.compile()to accept aQuickJSinstance directly and adapted promise resolution/error handling. - Updated internal workspace dependencies (
pac-proxy-agent→pac-resolver,pac-resolver→degenerator) and refreshed tests/error assertions.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Replaces quickjs-emscripten entries with quickjs-wasi and updates workspace links. |
| packages/pac-resolver/test/test.ts | Uses QuickJS.create() and updates identifier error assertion. |
| packages/pac-resolver/src/index.ts | Updates createPacResolver() to accept QuickJS from quickjs-wasi. |
| packages/pac-resolver/package.json | Switches degenerator to workspace:* and adds quickjs-wasi for development/tests. |
| packages/pac-proxy-agent/src/index.ts | Uses QuickJS.create() when loading PAC resolver. |
| packages/pac-proxy-agent/package.json | Moves to workspace:* pac-resolver and adds quickjs-wasi dependency. |
| packages/degenerator/test/test.ts | Uses QuickJS.create(), disposes VM in teardown, updates identifier error assertion. |
| packages/degenerator/src/compile.ts | Reworks compile flow to use quickjs-wasi VM API and updated promise bridging. |
| packages/degenerator/package.json | Adds quickjs-wasi for development/tests. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/pac-proxy-agent/src/index.ts:149
loadResolver()creates a new QuickJS instance unconditionally, but if the PAC file hash matches and you reusethis.resolver, the newly createdqjsis never disposed. This will leak WASM/VM memory over time. Consider computing the hash first (before creating the VM), or explicitly disposing the unusedqjsbefore returning.
// (Re)load the contents of the PAC file URI
const [qjs, code] = await Promise.all([
QuickJS.create(),
this.loadPacFile(),
]);
// Create a sha1 hash of the JS code
const hash = crypto.createHash('sha1').update(code).digest('hex');
if (this.resolver && this.resolverHash === hash) {
debug(
'Same sha1 hash for code - contents have not changed, reusing previous proxy resolver'
);
return this.resolver;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
@tootallnate/quickjs-emscripten with quickjs-wasi
Migrate degenerator, pac-resolver, and pac-proxy-agent from
@tootallnate/quickjs-emscripten to quickjs-wasi, a lighter-weight
QuickJS WASM runtime built on quickjs-ng with WASI reactor mode.
Key changes:
- degenerator: compile() now takes a QuickJS instance directly instead
of QuickJSWASMModule (no more qjs.newContext() — the QuickJS instance
IS the context). Host callbacks receive _this as first arg.
resolvePromise() returns {value}|{error} instead of VmCallResult.
Promise bridging calls executePendingJobs() after resolve/reject.
- pac-resolver: createPacResolver() takes QuickJS instead of
QuickJSWASMModule. Updated workspace dependency on degenerator.
- pac-proxy-agent: QuickJS.create() replaces getQuickJS(). quickjs-wasi
is now a runtime dependency (replaces @tootallnate/quickjs-emscripten).
Updated workspace dependency on pac-resolver.
- Tests: Updated error message assertion for quickjs-ng which formats
'process is not defined' without quotes around the identifier.
9f23502 to
72242b6
Compare
…PAC reload - degenerator: add quickjs-wasi as peerDependency (type appears in public API) - pac-resolver: add quickjs-wasi as peerDependency (type appears in public API) - pac-proxy-agent: store QuickJS instance, dispose previous VM when PAC is reloaded with new content, dispose unused VM when hash matches
Summary
Replaces
@tootallnate/quickjs-emscriptenwithquickjs-wasiacross all three PAC-related packages.quickjs-wasiis a lighter-weight QuickJS WASM runtime built on quickjs-ng with WASI reactor mode, supporting VM state snapshotting/restore.Changes
compile()now takes aQuickJSinstance directly (no moreqjs.newContext()— the instance IS the context).resolvePromise()returns{value}|{error}instead ofVmCallResult. Promise bridging callsexecutePendingJobs()after resolve/reject.createPacResolver()takesQuickJSinstead ofQuickJSWASMModule. Switched toworkspace:*dependency on degenerator.QuickJS.create()replacesgetQuickJS().quickjs-wasiis a runtime dependency. Switched toworkspace:*dependency on pac-resolver.Test Results
All tests pass: