Skip to content

fetch/api/abort/general.any.js WPT is flaky on Windows #1834

@KhafraDev

Description

@KhafraDev

fetch/api/abort/general.any.js has a test that occasionally prevents the worker from exiting, causing the CI to fail after it times out. This file is a conglomerate of ~50 tests, so skipping the file entirely is not a feasible solution. There is no way to disable individual tests either since undici uses the WPT test harness.

The test is only flaky on windows, and is most likely an issue where something isn't getting unref'd (considering it's testing aborts, it's likely AbortController/AbortSignal). Using powershell, you can run the wpt testing script x amount of times by doing 1..50 | % { npm run test:wpt }

It's possible to determine when a test times out using the following diff:

diff --git a/test/wpt/runner/runner/runner.mjs b/test/wpt/runner/runner/runner.mjs
index 8dfb21e8..a99b94fc 100644
--- a/test/wpt/runner/runner/runner.mjs
+++ b/test/wpt/runner/runner/runner.mjs
@@ -112,6 +112,13 @@ export class WPTRunner extends EventEmitter {
       })

       activeWorkers.add(worker)
+      const timeout = setTimeout(
+        () => {
+          console.log('test timed out', { worker, test })
+        },
+        meta.timeout === 'long' ? 60_000 : 10_000
+      )

       worker.on('message', (message) => {
         if (message.type === 'result') {
@@ -123,6 +130,7 @@ export class WPTRunner extends EventEmitter {

       worker.once('exit', () => {
         activeWorkers.delete(worker)
+        clearTimeout(timeout)

         if (activeWorkers.size === 0) {
           this.handleRunnerCompletion()

Calling worker.terminate doesn't do anything in this case because there may still be active refs; terminate works "as soon as possible". Another option is to send a message to the worker, and force it to shutdown, but there may be other implications by doing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions