René's URL Explorer Experiment


Title: test_runner: mock setInterval uses wrong interval after first time · Issue #50381 · nodejs/node · GitHub

Open Graph Title: test_runner: mock setInterval uses wrong interval after first time · Issue #50381 · nodejs/node

X Title: test_runner: mock setInterval uses wrong interval after first time · Issue #50381 · nodejs/node

Description: Version main Platform Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux Subsystem test What steps will reproduce the bug? When a mocked setInterval timer is triggered, the timers runAt ...

Open Graph Description: Version main Platform Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux Subsystem test What steps will reproduce the bug? When a mocked setInterv...

X Description: Version main Platform Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux Subsystem test What steps will reproduce the bug? When a mocked setInterv...

Opengraph URL: https://github.com/nodejs/node/issues/50381

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_runner: mock setInterval uses wrong interval after first time","articleBody":"### Version\n\nmain\n\n### Platform\n\nLinux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux\n\n### Subsystem\n\ntest\n\n### What steps will reproduce the bug?\n\nWhen a mocked `setInterval` timer is triggered, the timers runAt time is updated for the next time it should run [here](https://github.com/nodejs/node/blob/4f5db8b26d906f1cbe9f6a9ac2028b0f7ad88c91/lib/internal/test_runner/mock/mock_timers.js#L625). However , the increment is actually always 1, since the boolean flag `isInterval` is stored in the timer [here](https://github.com/nodejs/node/blob/4f5db8b26d906f1cbe9f6a9ac2028b0f7ad88c91/lib/internal/test_runner/mock/mock_timers.js#L268)\r\n\r\nPull request incoming.\r\n\r\n```js\r\ntest(\"setInterval uses the wrong interval\", async (t) =\u003e {\r\n  t.mock.timers.enable({ apis: [\"setInterval\"] });\r\n  const fn = t.mock.fn();\r\n\r\n  setInterval(fn, 1000);\r\n\r\n  assert.strictEqual(fn.mock.callCount(), 0);\r\n\r\n  t.mock.timers.tick(1000);\r\n\r\n  assert.strictEqual(fn.mock.callCount(), 1);\r\n\r\n  for (let i = 0; i \u003c 999; ++i) {\r\n    t.mock.timers.tick(1);\r\n  }\r\n\r\n  assert.strictEqual(fn.mock.callCount(), 1);\r\n});\r\n```\r\n\r\nfails with:\r\n\r\n```\r\n❯ ~/src/libs/node/node index.mjs\r\n﹣ aborting setTimeout clears wrong timer (2.795504ms) # SKIP\r\n﹣ aborting setTimeout after timer is already triggered clear wrong timer (0.20311ms) # SKIP\r\n✖ setInterval uses the wrong interval (24.795796ms)\r\n  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\r\n  \r\n  1000 !== 1\r\n  \r\n      at TestContext.\u003canonymous\u003e (file:///home/mfischer/src/tests/node-mock-timers/index.mjs:72:10)\r\n      at Test.runInAsyncScope (node:async_hooks:206:9)\r\n      at Test.run (node:internal/test_runner/test:631:25)\r\n      at Test.processPendingSubtests (node:internal/test_runner/test:374:18)\r\n      at Test.postRun (node:internal/test_runner/test:715:19)\r\n      at Test.run (node:internal/test_runner/test:673:12)\r\n      at async Test.processPendingSubtests (node:internal/test_runner/test:374:7) {\r\n    generatedMessage: true,\r\n    code: 'ERR_ASSERTION',\r\n    actual: 1000,\r\n    expected: 1,\r\n    operator: 'strictEqual'\r\n  }\r\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nsetInterval should use the correct interval\n\n### What do you see instead?\n\nsetInverval always uses interval 1 after first time\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/mika-fischer","@type":"Person","name":"mika-fischer"},"datePublished":"2023-10-25T08:04:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/50381/node/issues/50381"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:06c617bd-68a7-f29f-813d-e0a630f3e831
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD648:AA1C4:EDA5DC:1399577:6969A432
html-safe-nonce765039d59364e8e09f33c1024fac324b728bdf30d9b8d2620b84f43a961a3ff8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjQ4OkFBMUM0OkVEQTVEQzoxMzk5NTc3OjY5NjlBNDMyIiwidmlzaXRvcl9pZCI6IjY5MjY0OTg5OTU1OTI4NjQ4MTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac755b57b4e00bb7d8c2fc144c9a14319d6f617ee8de7eadc6a41cc24758abd111
hovercard-subject-tagissue:1960797186
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/50381/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4335ec7ce6b00f647333d7f625793bdd6ba0dddf42f5d749f16258d3738a9b88/nodejs/node/issues/50381
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4335ec7ce6b00f647333d7f625793bdd6ba0dddf42f5d749f16258d3738a9b88/nodejs/node/issues/50381
og:image:altVersion main Platform Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux Subsystem test What steps will reproduce the bug? When a mocked setInterv...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemika-fischer
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/50381#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F50381
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F50381
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/50381
Reloadhttps://github.com/nodejs/node/issues/50381
Reloadhttps://github.com/nodejs/node/issues/50381
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/50381
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 34.4k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 115k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.7k https://github.com/nodejs/node/issues
Pull requests 697 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects 3 https://github.com/nodejs/node/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/nodejs/node/security
Please reload this pagehttps://github.com/nodejs/node/issues/50381
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/50381
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/50381
#50384https://github.com/nodejs/node/pull/50384
test_runner: mock setInterval uses wrong interval after first timehttps://github.com/nodejs/node/issues/50381#top
#50384https://github.com/nodejs/node/pull/50384
test_runnerIssues and PRs related to the test runner subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22test_runner%22
https://github.com/mika-fischer
https://github.com/mika-fischer
mika-fischerhttps://github.com/mika-fischer
on Oct 25, 2023https://github.com/nodejs/node/issues/50381#issue-1960797186
#76https://github.com/nodejs/node/pull/76
herehttps://github.com/nodejs/node/blob/4f5db8b26d906f1cbe9f6a9ac2028b0f7ad88c91/lib/internal/test_runner/mock/mock_timers.js#L625
herehttps://github.com/nodejs/node/blob/4f5db8b26d906f1cbe9f6a9ac2028b0f7ad88c91/lib/internal/test_runner/mock/mock_timers.js#L268
test_runnerIssues and PRs related to the test runner subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22test_runner%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.