Skip to content

test: deflake long timer WPTs - #63106

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
marcopiraccini:wpt-fixture-bug
Sep 19, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
marcopiraccini:wpt-fixture-bug

Conversation

@marcopiraccini

@marcopiraccini marcopiraccini commented May 4, 2026

Copy link
Copy Markdown
Contributor

type-long-settimeout.any.js and type-long-setinterval.any.js in wpt/test-timers are flaky. Both arm setTimeout(assert_unreached, 100) as a guard and call done() from a timer whose delay overflows to 1 ms. Under load the guard can still fire after done(). testharness.js ignores exceptions once a test has a result, but in Node.js the throw becomes an uncaughtException, and the resulting Worker 'error' event can reach the runner before the completion message and fail the spec.

@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 May 4, 2026
@marcopiraccini
marcopiraccini marked this pull request as ready for review May 4, 2026 03:36
@codecov

codecov Bot commented May 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (357ba2f) to head (e5f48b4).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #63106   +/-   ##
=======================================
  Coverage   90.29%   90.29%           
=======================================
  Files         790      790           
  Lines      271882   271882           
  Branches    51899    51906    +7     
=======================================
+ Hits       245485   245502   +17     
+ Misses      16888    16881    -7     
+ Partials     9509     9499   -10     

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

@marcopiraccini
marcopiraccini force-pushed the wpt-fixture-bug branch 2 times, most recently from 731ede1 to f3f975a Compare May 24, 2026 12:26
@panva

panva commented May 24, 2026

Copy link
Copy Markdown
Member

You might want to update test/wpt/status/web-locks.json which has an expected uncaught rejection marked as flaky.

@panva

panva commented May 24, 2026

Copy link
Copy Markdown
Member

matching browser semantics

Can you elaborate? Is this rooted in the WPT runner browsers run, generally more context for review would be great.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 24, 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 May 24, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@marcopiraccini

Copy link
Copy Markdown
Contributor Author

matching browser semantics

Can you elaborate? Is this rooted in the WPT runner browsers run, generally more context for review would be great.

It's actually WPT semantic. In resources/testharness.js. The global error handler ignores exceptions once a test has a result (phase >= HAS_RESULT).
Our worker instead forwards a post-done() uncaughtException as a Worker 'error' event.

I think WPT is mirroring the browser's beaviour where the uncaugth exceptions after done are non-fatal

Editing the description and the comment.

@marcopiraccini

Copy link
Copy Markdown
Contributor Author

You might want to update test/wpt/status/web-locks.json which has an expected uncaught rejection marked as flaky.

Maybe I am missing something, but I don't think this change covers it. It seems held.https.any.js sets allow_uncaught_exception: true and rejects during the test, not after done().
The handler here is installed in add_completion_callback, so it only covers post-completion exceptions and won't reach that rejection.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

@github-actions github-actions Bot added the stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. label Aug 25, 2026

@panva panva 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.

I'd prefer to scope this workaround to test/wpt/test-timers.js. This changes error handling for every WPT suite, including swallowing unhandled rejections reported after completion, and removeAllListeners('uncaughtException') also removes unrelated handlers.

Can we use setScriptModifier() like in test-user-timing.js, limited to the two affected fixtures? For example:

'use strict';

const assert = require('assert');
const { basename } = require('path');
const { WPTRunner } = require('../common/wpt');

const runner = new WPTRunner('html/webappapis/timers', { concurrency: 1 });

runner.setScriptModifier((script) => {
  if (!['type-long-settimeout.any.js', 'type-long-setinterval.any.js']
    .includes(basename(script.filename))) return;

  // Cancel the failure timer when the test completes so it cannot throw
  // while the runner is still processing the completion message.
  const failureTimer = 'setTimeout(assert_unreached, 100);';
  assert(script.code.includes(failureTimer), `Unexpected contents of ${script.filename}`);
  script.code = script.code.replace(failureTimer,
                                    'const failureTimer = setTimeout(assert_unreached, 100);\n' +
                                    'add_completion_callback(() => clearTimeout(failureTimer));');
});

runner.runJsTests();

The failure timer would still catch missing completion, but couldn't throw after the test has finished.

@marcopiraccini marcopiraccini changed the title test: ignore late worker exceptions in WPT runner test: deflake long timer WPTs Sep 19, 2026
@panva panva added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Sep 19, 2026
@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Sep 19, 2026
@panva

panva commented Sep 19, 2026

Copy link
Copy Markdown
Member

@marcopiraccini please squash, rebase, and update the first commit to reflect the changes and the current PR title.

@panva panva removed the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Sep 19, 2026
type-long-settimeout.any.js and type-long-setinterval.any.js arm
setTimeout(assert_unreached, 100) as a guard. Under load it can fire
after done(), and the resulting uncaught exception can reach the WPT
runner before the completion message, failing the spec.

Use a script modifier to clear the guard timer from a completion
callback, for these two fixtures only. The guard still fails the test
when done() is never called.

Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Sep 19, 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 19, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added commit-queue PRs queued for automated landing through the Commit Queue. flaky-test Issues and PRs involving tests that fail intermittently in CI. labels Sep 19, 2026
@nodejs-github-bot
nodejs-github-bot merged commit c90c3dd into nodejs:main Sep 19, 2026
80 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in c90c3dd

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 19, 2026
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. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. 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.

5 participants