-
Notifications
You must be signed in to change notification settings - Fork 331
Allow postMessage-ing AbortSignal #948
Copy link
Copy link
Open
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: abortingAbortController and AbortSignalAbortController and AbortSignal
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: abortingAbortController and AbortSignalAbortController and AbortSignal
Currently communicating to a worker that work should be aborted is somewhat annoying. This is especially true for work that may be run in a synchronous loop as one can not simply send forward a
MessageChannelthat signals aborting, but rather you need to send aSharedArrayBufferthat can be synchronously read.I'd like to propose the ability to
.postMessageanAbortSignalso that we can communicate aborting to workers in a consistent way to aborting on the main thread. Ideally this would support the synchronous case as well (e.g. callingcontroller.abort()from the original thread would synchronously updatesignal.abortedin the other thread so that compute loops can simply doif (signal.aborted) { /* terminate work */ }).If there's interest, I would be willing to create a PR for this.