Skip to content

SharedWorker is racy #5362

Open
Open
@elkurin

Description

@elkurin

Shared worker instances with the same url, name and constructor origin must point to the same shared worker. However, since the spec says "in parallel run a worker", the shared worker instances might point to different shared workers.

Step 11.6: Otherwise, in parallel, run a worker given worker, urlRecord, outside settings, outside port, and options.
https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker

This happens because SharedWorkerGlobalScope is created after the algorithm is parallelized.

Step 6: For the global object, if is shared is true, create a new SharedWorkerGlobalScope object. Otherwise, create a new DedicatedWorkerGlobalScope object.
https://html.spec.whatwg.org/multipage/workers.html#worker-processing-model

Maybe we should create global scope before parallelizing the algorithm at #dom-sharedworker Step 11.6.

This issue is discussed partially at #5323.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions