Skip to content

fix(jsdom): support AbortSignal API#8704

Merged
sheremet-va merged 3 commits intovitest-dev:mainfrom
sheremet-va:fix/jsdom-abort-signal-api
Oct 14, 2025
Merged

fix(jsdom): support AbortSignal API#8704
sheremet-va merged 3 commits intovitest-dev:mainfrom
sheremet-va:fix/jsdom-abort-signal-api

Conversation

@sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Oct 13, 2025

Description

Fixes #8563

In jsdom AbortSignal API is used only in addEventListener.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit af0245e
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68ed054b02f8380008f7625c
😎 Deploy Preview https://deploy-preview-8704--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

})
const clearWindowErrors = catchWindowErrors(dom.window as any)

patchAddEventListener(dom.window)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this unpatch on teardown?

Copy link
Member Author

Choose a reason for hiding this comment

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

teardown removes the EventTarget from global so I don't think it needs to be unpatched

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I wondered about that, but just in case? I'm fine either way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, let's add it just in case

hi-ogawa
hi-ogawa previously approved these changes Oct 14, 2025
})
const clearWindowErrors = catchWindowErrors(dom.window as any)

patchAddEventListener(dom.window)
Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I wondered about that, but just in case? I'm fine either way.

AriPerkkio
AriPerkkio previously approved these changes Oct 14, 2025
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

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

Looks good. Patching globals just for JSDOM is fine as it's already simulating so much.

@sheremet-va sheremet-va dismissed stale reviews from AriPerkkio and hi-ogawa via 218c49a October 14, 2025 08:16
@sheremet-va sheremet-va merged commit f6690ed into vitest-dev:main Oct 14, 2025
10 of 14 checks passed
@sheremet-va sheremet-va deleted the fix/jsdom-abort-signal-api branch October 14, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to execute 'addEventListener' on 'EventTarget' when passing a signal from AbortController to addEventListener - vitest@"^4.0.0-beta.10"

3 participants