Skip to content

AbortSignal.timeout throws RangeError with any decimal number input #58592

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

Open
cprass opened this issue Jun 5, 2025 · 4 comments · May be fixed by #58594
Open

AbortSignal.timeout throws RangeError with any decimal number input #58592

cprass opened this issue Jun 5, 2025 · 4 comments · May be fixed by #58594

Comments

@cprass
Copy link

cprass commented Jun 5, 2025

Version

v24.1.0

Platform


Subsystem

No response

What steps will reproduce the bug?

The bug is easy to reproduce using the timeout function with a decimal.

AbortSignal.timeout(1.1)

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

It always produces the same error.

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

I'd expect it to work with all numbers, including decimal numbers, within the range of 0 and Number.MAX_SAFE_INTEGER. Browsers and other JS runtimes all seem to allow decimals. There is no mention of this special behavior in the NodeJS docs.

What do you see instead?

Uncaught:
RangeError [ERR_OUT_OF_RANGE]: The value of "delay" is out of range. It must be an integer. Received 1.1
    at AbortSignal.timeout (node:internal/abort_controller:239:5) {
  code: 'ERR_OUT_OF_RANGE'
}

Additional information

No response

@Renegade334
Copy link
Contributor

Renegade334 commented Jun 5, 2025

The web specification mandates that the parameter be validated as an unsigned integer.

ref: https://dom.spec.whatwg.org/#interface-AbortSignal

@cprass
Copy link
Author

cprass commented Jun 6, 2025

The web specification mandates that the parameter be validated as an unsigned integer.

ref: https://dom.spec.whatwg.org/#interface-AbortSignal

The spec defines how IDL types map to JavaScript https://webidl.spec.whatwg.org/#js-unsigned-long-long. Doesn't [EnforceRange] unsigned long long allow any JS number and coerces the value?

@bakkot
Copy link
Contributor

bakkot commented Jun 6, 2025

[EnforceRange] says

The Number will be rounded toward zero before being checked against its range.

The attribute is only about the upper and lower bounds, not about non-integer inputs. The example in that section has an input of -0.9 not throwing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@bakkot @cprass @Renegade334 and others