Skip to content

Editorial: queue a task to reject promise in InstallEvent.addRoutes - #1839

Merged
monica-ch merged 1 commit into
w3c:mainfrom
monica-ch:addroutes-queue-reject
Aug 4, 2026
Merged

Editorial: queue a task to reject promise in InstallEvent.addRoutes#1839
monica-ch merged 1 commit into
w3c:mainfrom
monica-ch:addroutes-queue-reject

Conversation

@monica-ch

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

Copy link
Copy Markdown
Collaborator

This is a small follow-up related to #1740.

The rejection path inside the [[service worker queue]] block of InstallEvent.addRoutes() was rejecting |promise| directly from inside the [[service worker queue]] (a parallel queue)". Rejecting a JS promise from a parallel queue crosses the event-loop/parallel boundary and is the same pattern that #1740 flags across the spec.

This PR:

  • Wraps the rejection in a Queue a task on the service worker's event loop, using the DOM manipulation task source, matching the existing resolve path a few lines below.
  • Adds an Abort these steps. after the rejection queue so we don't fall through to Set |serviceWorker|'s list of router rules and the follow-up resolve on the same promise.
  • Hoists Let |serviceWorkerEventLoop| be the current global object's event loop. above the [=queue/Enqueue=] block so both the reject and resolve tasks can reference it (and so the event loop is captured on the event-loop side, not inside the parallel queue).

Editorial only, no normative behavior change beyond making the failure path stop after rejecting (which it should already do — the previous text would set the rules and resolve after rejecting, which was a bug in the failure path).

This is a follow-up spun out of #1755, InstallEvent.addRoutes had the same reject-in-parallel bug, but sits outside the sections covered by any of those.

Refs: #1740


Preview | Diff

The rejection path in the [[service worker queue]] block was resolving/rejecting a JS promise directly from a parallel queue, which violates the same pattern that w3c#1740 flags. Wrap it in a Queue a task on the service worker event loop, and abort further steps so we don't also set the rules and resolve the same promise afterwards.

Refs: w3c#1740
@monica-ch
monica-ch marked this pull request as draft July 31, 2026 22:23
@monica-ch
monica-ch marked this pull request as ready for review August 4, 2026 00:10
@monica-ch

Copy link
Copy Markdown
Collaborator Author

@yoshisatoyanagisawa Can you also review this when you get a chance!

@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.

good catch!

@monica-ch
monica-ch merged commit 9e9fe27 into w3c:main Aug 4, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Aug 4, 2026
…1839)

SHA: 9e9fe27
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 Aug 4, 2026
…3c#1839)

SHA: 9e9fe27
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants