Skip to content

Allow postMessage-ing AbortSignal #948

Open
@Jamesernator

Description

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 MessageChannel that signals aborting, but rather you need to send a SharedArrayBuffer that can be synchronously read.

I'd like to propose the ability to .postMessage an AbortSignal so 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. calling controller.abort() from the original thread would synchronously update signal.aborted in the other thread so that compute loops can simply do if (signal.aborted) { /* terminate work */ }).

If there's interest, I would be willing to create a PR for this.

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interesttopic: abortingAbortController and AbortSignal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions