Skip to content

lib: validate AbortSignal.timeout delay per its WebIDL definition #58594

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Jun 6, 2025

Fixes: #58592

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 6, 2025
@himself65 himself65 force-pushed the himself65/2025/06/06/timer branch 2 times, most recently from 351dacb to 83f5055 Compare June 6, 2025 03:10
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.16%. Comparing base (b23648e) to head (364be70).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58594      +/-   ##
==========================================
+ Coverage   90.15%   90.16%   +0.01%     
==========================================
  Files         636      636              
  Lines      187891   187899       +8     
  Branches    36879    36888       +9     
==========================================
+ Hits       169386   169413      +27     
+ Misses      11272    11243      -29     
- Partials     7233     7243      +10     
Files with missing lines Coverage Δ
lib/internal/abort_controller.js 98.29% <100.00%> (+0.02%) ⬆️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@himself65 himself65 requested a review from jasnell June 7, 2025 06:57
@himself65 himself65 added commit-queue Add this label to land a pull request using GitHub Actions. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 8, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 8, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/58594
✔  Done loading data for nodejs/node/pull/58594
----------------------------------- PR info ------------------------------------
Title      lib: bypass `delay` in AbortSignal.timeout (#58594)
Author     Alex Yang <[email protected]> (@himself65)
Branch     himself65:himself65/2025/06/06/timer -> nodejs:main
Labels     author ready, needs-ci
Commits    1
 - lib: bypass `delay` in AbortSignal.timeout
Committers 1
 - Alex Yang <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/58594
Fixes: https://github.com/nodejs/node/issues/58592
Reviewed-By: Jake Yuesong Li <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/58594
Fixes: https://github.com/nodejs/node/issues/58592
Reviewed-By: Jake Yuesong Li <[email protected]>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 06 Jun 2025 02:54:17 GMT
   ✔  Approvals: 1
   ✔  - Jake Yuesong Li (@jakecastelli): https://github.com/nodejs/node/pull/58594#pullrequestreview-2907023450
   ✘  This PR needs to wait 118 more hours to land (or 0 hours if there is one more approval)
   ✘  Last GitHub CI failed
   ℹ  Last Full PR CI on 2025-06-08T02:12:11Z: https://ci.nodejs.org/job/node-test-pull-request/67324/
- Querying data for job/node-test-pull-request/67324/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/15514793432

@himself65 himself65 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 8, 2025
@panva panva removed commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jun 8, 2025
@panva
Copy link
Member

panva commented Jun 8, 2025

PRs need two reviews to be landable after 48 hours. With one review a 7 day wait period is observed. A passing CI is also required.

@nodejs-github-bot
Copy link
Collaborator

@panva
Copy link
Member

panva commented Jun 8, 2025

cc @nodejs/web-standards

panva

This comment was marked as outdated.

@panva panva added web-standards Issues and PRs related to Web APIs and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jun 8, 2025
@himself65 himself65 changed the title lib: bypass delay in AbortSignal.timeout lib: validate AbortSignal.timeout delay per its WebIDL definition Jun 9, 2025
@himself65 himself65 force-pushed the himself65/2025/06/06/timer branch 3 times, most recently from 0ca0bbb to 64e4c90 Compare June 9, 2025 09:30
@panva panva added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 9, 2025
@panva
Copy link
Member

panva commented Jun 9, 2025

I'll take care of the WPT update separately.

@himself65
Copy link
Member Author

thank u

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 9, 2025
@nodejs-github-bot
Copy link
Collaborator

@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 9, 2025
@nodejs-github-bot
Copy link
Collaborator

@panva panva removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 9, 2025
Copy link
Member

@panva panva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just relaxing this JS validation won't entirely fix the situation.

The rest of the codepath still only supports uint32 and anything bigger has its duration set to 1 instead. I'll look into it.

./node -e 'AbortSignal.timeout(Number.MAX_SAFE_INTEGER)'
(node:51580) TimeoutOverflowWarning: 9007199254740991 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.

Edit: I don't know what it would take for lib/internal/timers.js to support the range (0, Number.MAX_SAFE_INTEGER) in class Timeout.

@panva
Copy link
Member

panva commented Jun 9, 2025

cc @nodejs/timers ☝️

@himself65
Copy link
Member Author

I think maybe we should merge this PR first and change setTimeout behavior later. seems to be separate PR?

Just found webidl says setTimeout only supports a signed long int

@panva
Copy link
Member

panva commented Jun 9, 2025

I think maybe we should merge this PR first and change setTimeout behavior later. seems to be separate PR?

Right now large values are rejected, after this PR they will be accepted but the timeout will be set to 1 instead, so no, I don't think we should accept the PR as-is.

At best you could change this to the original uint32 but using WebIDL conversion, i.e. convertToInt('delay', delay, 32, opts) but we should also add a note to the documentation that only values up to 2147483647 are accepted.

@himself65 himself65 force-pushed the himself65/2025/06/06/timer branch from 64e4c90 to 70d006a Compare June 9, 2025 12:52
@himself65
Copy link
Member Author

commit updated.

according to the old code. I think we from only supports uint32 to uint32 + float + loose convert value

@panva panva added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. web-standards Issues and PRs related to Web APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AbortSignal.timeout throws RangeError with any decimal number input
5 participants