Skip to content

Client.postMessage() throwing for unloaded client is problematic #1291

@wanderview

Description

@wanderview

Currently Client.postMessage() says:

2. Let destination be the ServiceWorkerContainer object whose
service worker client is the context object’s service worker client,
or null if no match is found.

3. If destination is null, throw an "InvalidStateError" DOMException.

This is problematic for a few reasons:

  1. Most postMessage() implementations don't throw. They just silently consume the message if the other end is no longer listening. For example Worker.postMessage() and MessageChannel, etc.
  2. The lookup of the destination is presented as synchronous in the spec, but it must be async in any cross-process browser implementation.

If we wanted we could change postMessage() to return a promise, but its probably better to just silently eat the message.

I'm filing this issue in regards to web-platform-tests/wpt#10153

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions