Title: mock.timers ignores AbortSignal.timeout · Issue #60509 · nodejs/node · GitHub
Open Graph Title: mock.timers ignores AbortSignal.timeout · Issue #60509 · nodejs/node
X Title: mock.timers ignores AbortSignal.timeout · Issue #60509 · nodejs/node
Description: Version v24.10.0, v25.1.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? Execute this test: import { beforeEach, describe, it, mock } from "node:test"; import assert from "node:ass...
Open Graph Description: Version v24.10.0, v25.1.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? Execute this test: import { beforeEach, describe, it, mock } from "...
X Description: Version v24.10.0, v25.1.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? Execute this test: import { beforeEach, describe, it, mock } from &...
Opengraph URL: https://github.com/nodejs/node/issues/60509
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mock.timers ignores AbortSignal.timeout","articleBody":"### Version\n\nv24.10.0, v25.1.0\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.26100.0\nx64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nExecute this test:\n```js\nimport {\n beforeEach,\n describe,\n it,\n mock\n} from \"node:test\";\nimport assert from \"node:assert\";\n\ndescribe(\"test\", () =\u003e {\n beforeEach(() =\u003e {\n mock.timers.enable({ apis: [\"Date\", \"setTimeout\"] });\n });\n\n it(\"should test abort\", { timeout: 5000 }, async () =\u003e {\n const timeout = AbortSignal.timeout(10000);\n const catchSpy = mock.fn();\n const abortablePromise = new Promise((_, reject) =\u003e {\n timeout.addEventListener(\"abort\", () =\u003e {\n reject(new Error(\"promise rejected due to abort signal\"));\n });\n }).catch(catchSpy);\n assert.equal(catchSpy.mock.calls.length, 0);\n await Promise.resolve();\n mock.timers.tick(10000);\n await abortablePromise;\n assert.equal(catchSpy.mock.calls.length, 1);\n });\n});\n```\n\nIt times out.\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe timer tick also ticks the timeout AbortSignal and triggers listeners if applicable, or the mock.timers.enable option supports a new \"AbortSignal.timeout\" API.\n\n### What do you see instead?\n\nThe test times out before the abort signal is triggered.\n\n### Additional information\n\nIn node versions \u003c24, this results in a failing test after a few milliseconds with\n\"Promise resolution is still pending but the event loop has already resolved\".","author":{"url":"https://github.com/DerGernTod","@type":"Person","name":"DerGernTod"},"datePublished":"2025-10-31T10:41:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/60509/node/issues/60509"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:642bb6c8-b363-267a-80e9-f7179504a77f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D778:6A6D7:2C5332A:3F04934:6A4CFEE6 |
| html-safe-nonce | d23831039d7762cafdd2cc89e4866395dc6f7a15907aca0d0ee0afc9bc3334ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzc4OjZBNkQ3OjJDNTMzMkE6M0YwNDkzNDo2QTRDRkVFNiIsInZpc2l0b3JfaWQiOiIxOTM4NjU5NjA3MTIzNzE5NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0c37a0e2932e6baa110c297b83f84e765a24c88dafd11649326724bb704e45db |
| hovercard-subject-tag | issue:3574403495 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/60509/issue_layout |
| twitter:image | https://opengraph.githubassets.com/39015219e6983fef7d508b455628e58a554b08290385660a9d7bc62513d049e3/nodejs/node/issues/60509 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/39015219e6983fef7d508b455628e58a554b08290385660a9d7bc62513d049e3/nodejs/node/issues/60509 |
| og:image:alt | Version v24.10.0, v25.1.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? Execute this test: import { beforeEach, describe, it, mock } from "... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DerGernTod |
| hostname | github.com |
| expected-hostname | github.com |
| None | 31e4db13a9e20081f2fac78f441659a6576e582bbb15e153f9c7fb6473aa29f5 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fb70bd3c4b2bec429781b65419e912c66e2d5581 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width