You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node:test run does not respect abort signal #50583
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)
})
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.
Activity
everett1992 commentedon Nov 7, 2023
Maybe this is a documentation issue and
signalonly cancelswatch? If that is the case this is a feature request to makesignalable to cancel the current test run.test_runner: pass abortSignal to test files
test_runner: pass abortSignal to test files
test_runner: pass abortSignal to test files
test_runner: pass abortSignal to test files