Skip to content

Allow waitUntil to be called multiple times, async #771

Closed
@jakearchibald

Description

@jakearchibald

waitUntil must be called before returning to the event loop, but it may be called after that if one of its promises hasn't resolved.

respondWith should compose with this, and count as having called waitUntil in the initial turn. As in:

self.onfetch = event => {
  event.respondWith(doSomeThingToGetResponse().then(response => {
    event.waitUntil(doSomeCleanup);
    return response;
  }))
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions