Skip to content

node:test run does not respect abort signal #50583

@everett1992

Description

@everett1992

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)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions