Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone.js throws TypeError when passing AbortController as options to addEventListener #54831

Closed
zzmp opened this issue Mar 12, 2024 · 2 comments
Closed

Comments

@zzmp
Copy link
Contributor

zzmp commented Mar 12, 2024

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

window.addEventListener takes an options argument, which can be shaped as { signal: AbortSignal }. AbortController satisfies this interface, and can be passed to addEventListener in the native implementation:

window.addEventListener('keydown', () => {}, new AbortController)

However, zone.js is clever with passing the signal, and un-assigns and re-assigns it to taskData.options avoid passing it internally. taskData.options is initialized to the original options argument, so it is initialized to an instance of AbortController, for which signal is a getter. This results in a TypeError. Instead, for this to work in zone.js, you need to destructure:

window.addEventListener('keydown', () => {}, { signal: (new AbortController).signal })

zone.js should not be using the original options argument (to save memory) and assigning to it, as it is of an unknown type and the options properties may not be writable.

Please provide a link to a minimal reproduction of the bug

N/A - see explanation for one-liners

Please provide the exception or error you saw

TypeError: Cannot set property signal of [object AbortController] which has only a getter

Please provide the environment you discovered this bug in (run ng version)

zone.js: 0.14.4
Google Chrome: 122.0.6261.94 (Official Build) (arm64)

Anything else?

No response

@ngbot ngbot bot added this to the needsTriage milestone Mar 12, 2024
@JeanMeche
Copy link
Member

Hi, thank you for reporting this issue, this is already being tracked at #54142.

@JeanMeche JeanMeche closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants