Skip to content

fix(tests/node_compat): normalize underscored V8 flags - #34129

Merged
littledivy merged 2 commits into
mainfrom
orch/issue-110
May 16, 2026
Merged

littledivy merged 2 commits into
mainfrom
orch/issue-110

Conversation

@divybot

@divybot divybot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Node.js test suite writes V8 flags in both --expose-gc (hyphenated) and --expose_gc (underscored) form interchangeably — V8 normalizes them internally. Deno's node_compat runner extracts // Flags: lines from each test and forwards a curated subset as --v8-flags=..., but the extractor only matched the hyphenated spellings. Tests written with the underscored form were launched without the flag, so their first call to globalThis.gc() failed with:

TypeError: globalThis.gc is not a function
  globalThis.gc();
             ^

The fix normalizes _ → - after the leading -- before matching, so a single arm handles both spellings.

Five tests previously failed solely because of this. With the fix:

Test Before After
parallel/test-async-hooks-destroy-on-gc.js fail (globalThis.gc is not a function) pass
parallel/test-async-hooks-disable-gc-tracking.js fail (same) pass
parallel/test-async-hooks-prevent-double-destroy.js fail (same) pass
parallel/test-http-parser-bad-ref.js fail (same) pass
parallel/test-abortsignal-drop-settled-signals.mjs fail (same) now fails on a separate, unrelated AbortSignal-internals issue

The same normalization fixes --allow_natives_syntax (used by parallel/test-http-same-map.js), which previously also slipped through.

The runtime side already works: deno run --v8-flags=--expose-gc exposes globalThis.gc correctly. No runtime changes needed — fix is purely in tests/node_compat/mod.rs::parse_flags.

Closes denoland/orchid#110

Test plan

  • cargo test --test node_compat -- test-async-hooks-destroy-on-gc passes
  • cargo test --test node_compat -- test-async-hooks-disable-gc-tracking passes
  • cargo test --test node_compat -- test-async-hooks-prevent-double-destroy passes
  • cargo test --test node_compat -- test-http-parser-bad-ref passes
  • cargo test --test node_compat -- test-weakref (uses hyphenated --expose-gc) still passes — no regression
  • cargo clippy --tests -p node_compat_tests clean

🤖 Generated with Claude Code

The Node test suite uses `--expose_gc` and `--allow_natives_syntax`
(underscored) interchangeably with `--expose-gc` / `--allow-natives-syntax`
(hyphenated). V8 itself accepts both spellings, but the node_compat runner's
flag extractor only matched the hyphenated forms, so tests written with
underscores were launched without `--v8-flags=--expose-gc`. Their first call
to `globalThis.gc()` then failed with `TypeError: globalThis.gc is not a
function`.

Normalize underscores to hyphens before matching so both spellings produce
the same `--v8-flags=...` entry.

Closes denoland/orchid#110

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@divybot divybot changed the title node compat: expose globalThis.gc when --expose-gc / --v8-flags=--expose-gc is set fix(tests/node_compat): normalize underscored V8 flags May 16, 2026

@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.

Enable the newly passing tests

Add the four tests fixed by the underscored-flag normalization to the
default config.jsonc set so they run on CI (not just `--report` mode).

- parallel/test-async-hooks-destroy-on-gc.js
- parallel/test-async-hooks-disable-gc-tracking.js
- parallel/test-async-hooks-prevent-double-destroy.js
- parallel/test-http-parser-bad-ref.js

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@littledivy
littledivy merged commit 38b79c2 into main May 16, 2026
136 checks passed
@littledivy
littledivy deleted the orch/issue-110 branch May 16, 2026 18:25
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
## Summary

The Node.js test suite writes V8 flags in both `--expose-gc`
(hyphenated) and `--expose_gc` (underscored) form interchangeably — V8
normalizes them internally. Deno's node_compat runner extracts `//
Flags:` lines from each test and forwards a curated subset as
`--v8-flags=...`, but the extractor only matched the hyphenated
spellings. Tests written with the underscored form were launched without
the flag, so their first call to `globalThis.gc()` failed with:

```
TypeError: globalThis.gc is not a function
  globalThis.gc();
             ^
```

The fix normalizes `_` → `-` after the leading `--` before matching, so
a single arm handles both spellings.

Five tests previously failed solely because of this. With the fix:

| Test | Before | After |
|---|---|---|
| `parallel/test-async-hooks-destroy-on-gc.js` | fail (`globalThis.gc is
not a function`) | pass |
| `parallel/test-async-hooks-disable-gc-tracking.js` | fail (same) |
pass |
| `parallel/test-async-hooks-prevent-double-destroy.js` | fail (same) |
pass |
| `parallel/test-http-parser-bad-ref.js` | fail (same) | pass |
| `parallel/test-abortsignal-drop-settled-signals.mjs` | fail (same) |
now fails on a separate, unrelated AbortSignal-internals issue |

The same normalization fixes `--allow_natives_syntax` (used by
`parallel/test-http-same-map.js`), which previously also slipped
through.

The runtime side already works: `deno run --v8-flags=--expose-gc`
exposes `globalThis.gc` correctly. No runtime changes needed — fix is
purely in `tests/node_compat/mod.rs::parse_flags`.

Closes denoland/orchid#110

## Test plan

- [x] `cargo test --test node_compat -- test-async-hooks-destroy-on-gc`
passes
- [x] `cargo test --test node_compat --
test-async-hooks-disable-gc-tracking` passes
- [x] `cargo test --test node_compat --
test-async-hooks-prevent-double-destroy` passes
- [x] `cargo test --test node_compat -- test-http-parser-bad-ref` passes
- [x] `cargo test --test node_compat -- test-weakref` (uses hyphenated
`--expose-gc`) still passes — no regression
- [x] `cargo clippy --tests -p node_compat_tests` clean

---------

Co-authored-by: divybot <divybot@users.noreply.github.com>
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