fix(ext/node): add v8.startupSnapshot API polyfill#34189
Merged
Conversation
Adds an API-surface polyfill for `v8.startupSnapshot` on `node:v8` so that modules destructuring `setDeserializeMainFunction`, `addSerializeCallback`, `addDeserializeCallback`, or `isBuildingSnapshot` load without throwing. Deno does not implement `--build-snapshot` / `--snapshot-blob`, so this is not a real snapshot lifecycle: - `isBuildingSnapshot()` returns `false`. - `setDeserializeMainFunction(fn, data)` invokes `fn(data)` synchronously so scripts written for snapshot deserialization still execute their entry point in plain Deno runs. - `addSerializeCallback` / `addDeserializeCallback` store the callbacks but never invoke them. The two node_compat tests that exercise the full snapshot lifecycle (`parallel/test-snapshot-console.js`, `parallel/test-snapshot-stack-trace-limit.js`) are marked `ignore: true` with the same reason as the other `test-snapshot-*` entries because they need actual `--build-snapshot` / `--snapshot-blob` support to pass. Closes denoland/orchid#127 Co-Authored-By: Divy Srivastava <[email protected]>
littledivy
enabled auto-merge (squash)
May 17, 2026 13:22
littledivy
added a commit
to crowlKats/deno
that referenced
this pull request
Jun 10, 2026
## Summary
Adds an API-surface polyfill for `v8.startupSnapshot` on `node:v8` so
that
modules destructuring `setDeserializeMainFunction`,
`addSerializeCallback`,
`addDeserializeCallback`, or `isBuildingSnapshot` load without throwing.
Deno does not implement `--build-snapshot` / `--snapshot-blob`, so this
is
not a real snapshot lifecycle:
- `isBuildingSnapshot()` returns `false`.
- `setDeserializeMainFunction(fn, data)` invokes `fn(data)`
synchronously so
scripts written for snapshot deserialization still execute their entry
point in plain Deno runs.
- `addSerializeCallback` / `addDeserializeCallback` store the callbacks
but
never invoke them (there is no serialize/deserialize phase).
The two node_compat tests that exercise the full snapshot lifecycle
(`parallel/test-snapshot-console.js`,
`parallel/test-snapshot-stack-trace-limit.js`)
are marked `ignore: true` with the same reason as the other
`test-snapshot-*`
entries because they need actual `--build-snapshot` / `--snapshot-blob`
support to pass. The minimum required by the issue — exposing
`startupSnapshot` so the destructure no longer throws — is in place.
Closes denoland/orchid#127
## Test plan
- [x] `deno fmt` clean
- [x] `deno lint` clean on changed files
- [x] Manual smoke test: `require('node:v8').startupSnapshot` exposes
the
4 methods, `isBuildingSnapshot()` returns `false`, and
`setDeserializeMainFunction(fn)` invokes `fn`
- [x] New unit tests in `tests/unit_node/v8_test.ts` cover the API
surface
- [x] `cargo test --test node_compat -- test-snapshot-console.js` now
reports
`ignored` instead of failing
- [x] `cargo test --test node_compat -- snapshot-stack-trace-limit.` now
reports `ignored` instead of failing
Co-authored-by: divybot <[email protected]>
Co-authored-by: Divy Srivastava <[email protected]>
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.
Summary
Adds an API-surface polyfill for
v8.startupSnapshotonnode:v8so thatmodules destructuring
setDeserializeMainFunction,addSerializeCallback,addDeserializeCallback, orisBuildingSnapshotload without throwing.Deno does not implement
--build-snapshot/--snapshot-blob, so this isnot a real snapshot lifecycle:
isBuildingSnapshot()returnsfalse.setDeserializeMainFunction(fn, data)invokesfn(data)synchronously soscripts written for snapshot deserialization still execute their entry
point in plain Deno runs.
addSerializeCallback/addDeserializeCallbackstore the callbacks butnever invoke them (there is no serialize/deserialize phase).
The two node_compat tests that exercise the full snapshot lifecycle
(
parallel/test-snapshot-console.js,parallel/test-snapshot-stack-trace-limit.js)are marked
ignore: truewith the same reason as the othertest-snapshot-*entries because they need actual
--build-snapshot/--snapshot-blobsupport to pass. The minimum required by the issue — exposing
startupSnapshotso the destructure no longer throws — is in place.Closes denoland/orchid#127
Test plan
deno fmtcleandeno lintclean on changed filesrequire('node:v8').startupSnapshotexposes the4 methods,
isBuildingSnapshot()returnsfalse, andsetDeserializeMainFunction(fn)invokesfntests/unit_node/v8_test.tscover the API surfacecargo test --test node_compat -- test-snapshot-console.jsnow reportsignoredinstead of failingcargo test --test node_compat -- snapshot-stack-trace-limit.nowreports
ignoredinstead of failing