Skip to content

Editorial: queue a task in Client / Clients API - #1836

Merged
monica-ch merged 1 commit into
w3c:mainfrom
monica-ch:queue-task-clients-api
Jul 23, 2026
Merged

Editorial: queue a task in Client / Clients API#1836
monica-ch merged 1 commit into
w3c:mainfrom
monica-ch:queue-task-clients-api

Conversation

@monica-ch

@monica-ch monica-ch commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Updates to:

  • client-postmessage-options — queue tasks to fire messageerror and dispatch message on the target client's responsible event loop.
  • clients-get — restructured per @yoshisatoyanagisawa's suggestion to queue once and run "invoke Resolve Get Client Promise" + "abort" as substeps; also queues the fall-through resolve.
  • clients-claim — queue the final resolve with undefined on the promise's responsible event loop.

All of these resolved/rejected promises or fired events directly from an "in parallel" block, which violates the "don't touch JS objects from parallel" rule.

This is part 4/6 of #1740. Split out from #1755 for focused review.


Preview | Diff

…ients API

- Client.postMessage(): queue tasks to fire messageerror and dispatch message on the target client's responsible event loop.
- Clients.get(id): restructure per review to queue once and run invoke+abort in substeps; also queue the fall-through resolve.
- Clients.claim(): queue the final resolve with undefined on the promise's responsible event loop.

Refs: w3c#1740

@yoshisatoyanagisawa yoshisatoyanagisawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@monica-ch
monica-ch merged commit 1bcbd24 into w3c:main Jul 23, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Jul 23, 2026
…ients API (#1836)

SHA: 1bcbd24
Reason: push, by monica-ch

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit to asleekgeek/ServiceWorker that referenced this pull request Jul 24, 2026
…ients API (w3c#1836)

SHA: 1bcbd24
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@asutherland

Copy link
Copy Markdown

I think the postMessage changes may be incorrect; the event dispatch was already happening under the auspices of:

Add a task that runs the following steps to destination ’s client message queue

The clients-get and clients-claim changes seem correct though.

@monica-ch

Copy link
Copy Markdown
Collaborator Author

Thanks for catching this @asutherland! Opened #1844 to remove the two nested Queue a task wrappers per your point — the outer Add a task ... to |destination|'s client message queue already handles the parallel→event-loop crossing with the correct task source. Would appreciate your review whenever you get a chance.

monica-ch added a commit that referenced this pull request Aug 12, 2026
…nt.postMessage (#1844)

The fire messageerror and Dispatch message steps already run inside a task on |destination|'s client message queue, so wrapping them in an additional Queue a task on |targetClient|'s responsible event loop is redundant (both queues target the destination client's event loop) and potentially incorrect (the outer client message queue task source is superseded by the inner DOM manipulation task source).

This reverts the Client.postMessage changes from #1836, per @asutherland's post-merge feedback on that PR. The Clients.get and Clients.claim changes from #1836 are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants