Skip to content

fix(ext/node): add v8.startupSnapshot API polyfill#34189

Merged
littledivy merged 1 commit into
mainfrom
orch/divybot-127
May 17, 2026
Merged

fix(ext/node): add v8.startupSnapshot API polyfill#34189
littledivy merged 1 commit into
mainfrom
orch/divybot-127

Conversation

@divybot

@divybot divybot commented May 17, 2026

Copy link
Copy Markdown
Contributor

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

  • deno fmt clean
  • deno lint clean on changed files
  • Manual smoke test: require('node:v8').startupSnapshot exposes the
    4 methods, isBuildingSnapshot() returns false, and
    setDeserializeMainFunction(fn) invokes fn
  • New unit tests in tests/unit_node/v8_test.ts cover the API surface
  • cargo test --test node_compat -- test-snapshot-console.js now reports
    ignored instead of failing
  • cargo test --test node_compat -- snapshot-stack-trace-limit. now
    reports ignored instead of failing

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 littledivy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy
littledivy enabled auto-merge (squash) May 17, 2026 13:22
@littledivy
littledivy merged commit a7fb5ef into main May 17, 2026
136 checks passed
@littledivy
littledivy deleted the orch/divybot-127 branch May 17, 2026 13:50
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants