-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deno resource leak test false positive when using filter #25235
Comments
Smaller reproduction: File import * as child_process from "node:child_process";
const worker = "foo.ts";
Deno.test("a", async () => {
const cp = child_process.spawn(Deno.execPath(), [worker], {});
await new Promise((r) => setTimeout(r, 200));
cp.kill();
});
Deno.test("b", async () => {
const cp = child_process.spawn(Deno.execPath(), [worker], {});
await new Promise((r) => setTimeout(r, 200));
cp.kill();
}); File await new Promise((r) => setTimeout(r, 9999)); |
The reproduction you provided is not correct @marvinhagemeister. The reported leak is genuine. You are just not waiting for the process to actually exit after calling cp.kill. You have to wait for the "exit" event to fire on the sub process. This is because subprocesses do not die synchronously on Unix. Calling cp.exit just sends the subprocess a signal (like SIGTERM) that the sub process can do with whatever it wants. For SIGTERM for example, most processes would shut down pretty quickly. However, that is not guaranteed. A process can just ignore the signal you send it. Because of that you always have to wait for the process to actually exit. And with node:child_process you do that by waiting for the exit event. |
Related evanw/esbuild#3701 |
I think the cases leak ops flakily and that is more likely happen when the 2 cases run together. I don't think this is an issue of filtering. I was able to reproduce the issue with the filter enabled:
|
Version: Deno 1.46.0
bug
deno resource leak test false positive when using filter
reproduce
actual
deno resource leak test false positive when using filter
expected
additional
Found this bug when evanw/esbuild#3896
The text was updated successfully, but these errors were encountered: