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

node:test run does not respect abort signal #50583

Closed
everett1992 opened this issue Nov 7, 2023 · 1 comment · Fixed by #50630
Closed

node:test run does not respect abort signal #50583

everett1992 opened this issue Nov 7, 2023 · 1 comment · Fixed by #50630
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@everett1992
Copy link
Contributor

everett1992 commented Nov 7, 2023

Version

20.9.0

Platform

Linux ua0683ea36b1857.ant.amazon.com 5.15.0-88-generic #98~20.04.1-Ubuntu SMP Mon Oct 9 16:43:45 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

test runner

What steps will reproduce the bug?

# run.mjs
import { run } from 'node:test';
import { tap } from 'node:test/reporters';
import process from 'node:process';

const signal = AbortSignal.timeout(10)
run({ files: ['test.mjs'], signal })
  .compose(tap)
  .pipe(process.stdout);
# test.mjs

import { test } from 'node:test'
import { setTimeout } from 'timers/promises'

test('a test', async () =>setTimeout(10_000))
node ./run.mjs

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

I would expect the run to timeout and error after 10ms, but instead it runs for 10 seconds.

What do you see instead?

The test runs for 10 seconds and completes successfully.

Additional information

I see the same behavior whether I use AbortSignal.timeout(10), AbortSignal.aborted(), or ac= new AbortController(); setTimeout(() => ac.abort(), 10).

Setting timeout: 10 throws as I expected.

import { test } from 'node:test'
import { setTimeout } from 'timers/promises'

test('a test', async () => {
  await setTimeout(10_000)
})
@everett1992
Copy link
Contributor Author

Maybe this is a documentation issue and signal only cancels watch? If that is the case this is a feature request to make signal able to cancel the current test run.

@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Nov 8, 2023
nodejs-github-bot pushed a commit that referenced this issue Nov 10, 2023
PR-URL: #50630
Fixes: #50583
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
targos pushed a commit that referenced this issue Nov 11, 2023
PR-URL: #50630
Fixes: #50583
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
targos pushed a commit that referenced this issue Nov 14, 2023
PR-URL: #50630
Fixes: #50583
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
UlisesGascon pushed a commit that referenced this issue Dec 11, 2023
PR-URL: #50630
Fixes: #50583
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants