Skip to content

test: deflake util.throttle tests - #66034

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:deflake-util-debounce-throttle
Sep 15, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:deflake-util-debounce-throttle

Conversation

@panva

@panva panva commented Sep 15, 2026

Copy link
Copy Markdown
Member

Short throttle windows can expire between synchronous calls when the process is descheduled. Delayed timer dispatch can also release two queued calls together, invalidating the strict test's spacing assertion.

Move timing checks to a separate test with mocked timers and a matching libuv clock. Cover both punctual and delayed dispatch, and keep real async_hooks timer-allocation checks with windows canceled before expiry.

Refs: #65899
Refs: https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu2404_sharedlibs_openssl111_x64/59189/
Refs: https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel8-s390x/58602/

Assisted-by: Codex

---
duration_ms: 399.938
exitcode: 1
severity: fail
stack: |-
  node:assert:173
    throw err;
    ^

  AssertionError [ERR_ASSERTION]: function should not have been called at /home/iojs/build/workspace/node-test-commit-linuxone/test/parallel/test-util-throttle.js:11
  called with arguments: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

    assert(times[3] - times[2] >= 25)

      at /home/iojs/build/workspace/node-test-commit-linuxone/test/parallel/test-util-throttle.js:293:5 {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: false,
    expected: true,
    operator: '==',
    diff: 'simple'
  }, Promise {
    <rejected> AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

      assert(times[3] - times[2] >= 25)

        at /home/iojs/build/workspace/node-test-commit-linuxone/test/parallel/test-util-throttle.js:293:5 {
      generatedMessage: true,
      code: 'ERR_ASSERTION',
      actual: false,
      expected: true,
      operator: '==',
      diff: 'simple'
    }
  }
      at process.mustNotCall (/home/iojs/build/workspace/node-test-commit-linuxone/test/common/index.js:570:12)
      at process.emit (node:events:514:20)
      at emitUnhandledRejection (node:internal/process/promises:182:13)
      at throwUnhandledRejectionsMode (node:internal/process/promises:318:19)
      at processPromiseRejections (node:internal/process/promises:405:17)
      at process.processTicksAndRejections (node:internal/process/task_queues:106:37) {
    generatedMessage: false,
    code: 'ERR_ASSERTION',
    actual: undefined,
    expected: undefined,
    operator: 'fail',
    diff: 'simple'
  }

  Node.js v27.0.0-pre
...

Short throttle windows can expire between synchronous calls when the
process is descheduled. Delayed timer dispatch can also release two
queued calls together, invalidating the strict test's spacing assertion.

Move timing checks to a separate test with mocked timers and a matching
libuv clock. Cover both punctual and delayed dispatch, and keep real
async_hooks timer-allocation checks with windows canceled before expiry.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
@panva
panva requested a review from jasnell September 15, 2026 12:45
@panva panva added flaky-test Issues and PRs involving tests that fail intermittently in CI. fast-track PRs proposed for a shorter-than-standard waiting period before landing. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @panva. Please 👍 to approve.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Sep 15, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 15, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (26dbe11) to head (ed130fc).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66034      +/-   ##
==========================================
- Coverage   90.23%   90.22%   -0.02%     
==========================================
  Files         789      789              
  Lines      270415   270476      +61     
  Branches    51756    51740      -16     
==========================================
+ Hits       244018   244027       +9     
- Misses      16868    16921      +53     
+ Partials     9529     9528       -1     

see 28 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.

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 15, 2026

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

assert.deepStrictEqual(await Promise.all([first, recursive]), [1, 2]);
assert.deepStrictEqual(values, [1, 2]);
}
})().then(common.mustCall()).finally(() => mock.reset());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
})().then(common.mustCall()).finally(() => mock.reset());
})().finally(() => mock.reset()).then(common.mustCall());

@nodejs-github-bot
nodejs-github-bot merged commit 84e9174 into nodejs:main Sep 15, 2026
95 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 84e9174

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 15, 2026
@panva
panva deleted the deflake-util-debounce-throttle branch September 15, 2026 16:06
aduh95 pushed a commit that referenced this pull request Sep 16, 2026
Short throttle windows can expire between synchronous calls when the
process is descheduled. Delayed timer dispatch can also release two
queued calls together, invalidating the strict test's spacing assertion.

Move timing checks to a separate test with mocked timers and a matching
libuv clock. Cover both punctual and delayed dispatch, and keep real
async_hooks timer-allocation checks with windows canceled before expiry.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: #66034
Refs: #65899
Refs: https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu2404_sharedlibs_openssl111_x64/59189/
Refs: https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel8-s390x/58602/
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95 pushed a commit that referenced this pull request Sep 17, 2026
Short throttle windows can expire between synchronous calls when the
process is descheduled. Delayed timer dispatch can also release two
queued calls together, invalidating the strict test's spacing assertion.

Move timing checks to a separate test with mocked timers and a matching
libuv clock. Cover both punctual and delayed dispatch, and keep real
async_hooks timer-allocation checks with windows canceled before expiry.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: #66034
Refs: #65899
Refs: https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu2404_sharedlibs_openssl111_x64/59189/
Refs: https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel8-s390x/58602/
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. fast-track PRs proposed for a shorter-than-standard waiting period before landing. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants