Commit 483096d
fix(ext/node): flesh out node:trace_events polyfill (#34216)
## Summary
The `node:trace_events` polyfill was a stub — `createTracing` returned
an
object with no `.enable`/`.disable` methods and `getEnabledCategories`
always returned `""`. This fleshes out the polyfill enough that the
four ignored compat tests now run end-to-end.
- `createTracing` validates input, returns a `Tracing` with `enabled` /
`categories` properties and `enable()`/`disable()` methods, and emits
the `>10` instances memory-leak warning.
- `getEnabledCategories()` returns `undefined` when no instance is
enabled, otherwise the comma-joined union of every enabled instance's
categories.
- `internalBinding('trace_events')` now exposes `trace(phase, cat, name,
id, scope)` and `getCategoryEnabledBuffer(cat)` (with refcount
semantics) so fixtures going through `internal/test/binding` observe
the same state as the public API.
- When `node.async_hooks` is enabled, `setTimeout` / `setImmediate` are
wrapped to emit `b`/`e` events with `cat="node,node.async_hooks"`.
On process exit each isolate writes its recorded events; workers
write per-thread slice files in `cwd` and the main isolate aggregates
them into a single `node_trace.${rotation}.log` so consumers see one
combined log (matching Node's process-wide `TracingController`
behavior).
- `--trace-event-categories` is now plumbed through `node_shim` →
`child_process` as `DENO_NODE_TRACE_EVENT_CATEGORIES`. The node
bootstrap (`01_require.js`) reads it in every isolate (main +
workers), pre-enables the listed categories, and pushes the flag
back onto `process.execArgv` so test fixtures that probe `execArgv`
see the expected shape.
Enables in `tests/node_compat/config.jsonc`:
- `parallel/test-trace-events-api.js`
- `parallel/test-trace-events-async-hooks-dynamic.js`
- `parallel/test-trace-events-async-hooks-worker.js`
- `parallel/test-trace-events-get-category-enabled-buffer.js`
Closes denoland/orchid#136
## Test plan
- [x] `cargo test --test node_compat -- test-trace-events-api.js`
- [x] `cargo test --test node_compat --
test-trace-events-async-hooks-dynamic.js`
- [x] `cargo test --test node_compat --
test-trace-events-async-hooks-worker.js`
- [x] `cargo test --test node_compat --
test-trace-events-get-category-enabled-buffer.js`
- [x] `cargo test --test node_compat --
test-trace-events-dynamic-enable-workers-disabled.js` (already-passing
test still passes)
- [x] `cargo test -p node_shim` (127 tests pass)
- [x] `cargo clippy --bin deno`
---------
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>1 parent 53de64d commit 483096d
7 files changed
Lines changed: 430 additions & 25 deletions
File tree
- ext/node
- ops
- polyfills
- internal
- libs/node_shim
- tests/node_compat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
| 94 | + | |
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
| |||
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
| 122 | + | |
112 | 123 | | |
113 | 124 | | |
114 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
3157 | 3158 | | |
3158 | 3159 | | |
3159 | 3160 | | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
3160 | 3188 | | |
3161 | 3189 | | |
3162 | 3190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
208 | 214 | | |
209 | 215 | | |
210 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1496 | 1496 | | |
1497 | 1497 | | |
1498 | 1498 | | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1499 | 1502 | | |
1500 | 1503 | | |
1501 | 1504 | | |
| |||
0 commit comments