Skip to content

Commit 898ed17

Browse files
divybotlittledivy
andauthored
chore: regression test for process._getActiveHandles() in 'exit' handler (#34191)
## Summary Adds a regression test that pins the fix from #34101 against the exact reproduction in [#34187](#34187): a CJS module that lazy-loads `node:http` via `setImmediate`, then calls `process._getActiveHandles()` (plus `_getActiveRequests` / `getActiveResourcesInfo`) from a `process.on('exit', ...)` handler. Before #34101 this threw `TypeError: process._getActiveHandles is not a function`. With the active-process-resources polyfills now in place, the snippet runs and prints `[]` like Node does. The new spec test ensures we don't regress. ## Test plan - [x] `cargo test --package specs_tests --test specs node::process_get_active_handles_on_exit` passes - [x] Running `target/debug/deno run -A repro.cjs` matches Node's behavior Closes denoland/orchid#131 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
1 parent 19e63a0 commit 898ed17

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tests": {
3+
"get_active_handles_on_exit": {
4+
"args": "run -A repro.cjs",
5+
"output": "handles=0\nrequests=0\nok\n"
6+
}
7+
}
8+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Regression test for https://github.com/denoland/deno/issues/34187
2+
// `process._getActiveHandles()` must be callable from the `'exit'` event
3+
// handler in a CJS module that lazy-loads `node:http`.
4+
5+
setImmediate(function () {
6+
require("http");
7+
});
8+
9+
var i = setInterval(function () {
10+
setImmediate(process.exit);
11+
}, 10);
12+
i.unref();
13+
14+
process.on("exit", logstuff);
15+
16+
function logstuff() {
17+
if (typeof process._getActiveHandles !== "function") {
18+
throw new TypeError("process._getActiveHandles is not a function");
19+
}
20+
if (typeof process._getActiveRequests !== "function") {
21+
throw new TypeError("process._getActiveRequests is not a function");
22+
}
23+
if (typeof process.getActiveResourcesInfo !== "function") {
24+
throw new TypeError("process.getActiveResourcesInfo is not a function");
25+
}
26+
console.log("handles=" + process._getActiveHandles().length);
27+
console.log("requests=" + process._getActiveRequests().length);
28+
console.log("ok");
29+
}

0 commit comments

Comments
 (0)