Skip to content
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

Sanitizer reports leak, even if count of pending ops before and after test is identical #22928

Closed
lucacasonato opened this issue Mar 14, 2024 · 1 comment
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@lucacasonato
Copy link
Member

const listener = Deno.listen({ port: 8080 });

const conn1 = await Deno.connect({ port: 8080 });
const conn2 = await listener.accept();

(async () => {
  while (true) {
    await conn1.write(new TextEncoder().encode("Hello World"));
    await conn2.read(new Uint8Array(11));
  }
})();

Deno.test("hello world", async () => {
  await new Promise((resolve) => setTimeout(resolve, 1000));
});

In Deno 1.40.0 this works fine.

In Deno 1.41.2 this errors with:

running 1 test from ./test.ts
hello world ... FAILED (1s)

 ERRORS 

hello world => ./test.ts:13:6
error: Leaks detected:
  - An async call to op_read was started before the test, but completed during the test. Async operations should not complete in a test if they were not started in that test.
  - An async call to op_read was started in this test, but never completed.
To get more details where leaks occurred, run again with the --trace-leaks flag.

 FAILURES 

hello world => ./test.ts:13:6

FAILED | 0 passed | 1 failed (1s)

error: Test failed

The issue is that we were previously comparing the count of pending ops before and after the test (which in this example will be identical), but now we are comparing the actual ops completing or not. This means that a loop reading from a subprocess stdout (esbuild) in global scope, will cause leaks here, even though in reality nothing is leaking (the count of ongoing read operations is the same before and after the test).

Version: Deno 1.41.2

@lucacasonato lucacasonato added bug Something isn't working correctly testing related to deno test and coverage labels Mar 14, 2024
@dsherret
Copy link
Member

Some glitch created two issues. Closing in favour of #22926

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage
Projects
None yet
Development

No branches or pull requests

2 participants