Skip to content

The type of postMessage is too permissive #2

Closed
@gbagan

Description

@gbagan

@JordanMartinez

In the current implementation of web-workers, worker # postMessage a accepts any type for a.
But, in the documentation, it is said that the posted message must be serializable which is equivalent to be a correct input of
structuredClone.
So I propose to implement a type class Serializable
and replace the signature of postMessage with

forall a. Serializable a => a -> Worker -> Effect Unit

@natefaubion said that it implemented something similar in
https://github.com/natefaubion/purescript-node-workerbees/blob/main/src/Node/WorkerBees.purs#L112-L150

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions