Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does accessing ExtendableEvent's extend lifetime promises race? #931

Closed
jungkees opened this issue Jul 18, 2016 · 5 comments
Closed

Does accessing ExtendableEvent's extend lifetime promises race? #931

jungkees opened this issue Jul 18, 2016 · 5 comments
Milestone

Comments

@jungkees
Copy link
Collaborator

@annevk pointed out there can be a race in accessing ExtendableEvent’s extend lifetime promises:
72315b9#commitcomment-18283685

I think it's a fair point as now e.waitUntil(f) can be called async.

@jungkees jungkees added this to the Version 1 milestone Jul 18, 2016
jungkees referenced this issue Jul 18, 2016
Remove the unnecessary steps that handled uncaught runtime script
errors in the install/activate/fetch event dispatch tasks. (DOM
dispatch algorithm takes care of it.) Also, make the related steps be
more precise.

Fixes #924
@jakearchibald
Copy link
Contributor

Feels like Set <var>extendLifetimePromises</var> to a copy of should go before the parallel steps, but If the length of <var>extendLifetimePromises</var> does not equal also needs to be in the service worker thread, so I guess a task needs to be queued for that?

@jakearchibald
Copy link
Contributor

F2F:

  • Set <var>extendLifetimePromises</var> to a copy of happening before parallel doesn't seem to be an issue, since it's only ever going to be more promises, which we want to catch
  • We need to look at the spec language for "waiting for all" to see if it queues a microtask

@jungkees
Copy link
Collaborator Author

Having discussed with @annevk, I will first have to move the "When dispatching an event e that uses the ExtendableEvent interface" steps to right after the actual (dispatching) actions. I'll define some general wrapper that dispatches the event and run these steps, and make it invoked from Handle Fetch and Handle Functional Events.

The OP still should be addressed here.

@jungkees
Copy link
Collaborator Author

@domenic suggested we use a reference count approach over the current promise-copying-and-checking one. Will try to come up with it.

jungkees added a commit that referenced this issue Nov 23, 2016
Introduce Extend Service Worker Lifetime algorithm

This replaces the steps that monkeypatched the extension of the service
worker's lifetime with an algorithm that is explicitly invoked after the
steps that dispatch the extendable events.

This also changes to use "create an event" algorithm in DOM spec.

This also adds an event as a param to Handle Functional Event.

Related issue: #931 (comment).
@jungkees
Copy link
Collaborator Author

jungkees commented Nov 23, 2016

Addressed #931 (comment): c2a518b.

Addressed #931 (comment): 6c1f3fe.

jungkees added a commit that referenced this issue Jan 5, 2017
(1) This changes the approach to unsetting the extendable events'
extensions allowed flag. This change introduced a reference count based
approach instead of the promise-copying-and-checking approach.

(2) This also extends the opportunities of the lifetime extension by
allowing calling waitUntil() within microtasks queued by the given
promise's Promise.prototype.then callback.

Related issues:
 - #931 (1)
 - #935 (2)
 - #1039 (2)
jungkees added a commit that referenced this issue Jan 9, 2017
(1) This changes the approach to unsetting the extendable events'
extensions allowed flag. This change introduced a reference count based
approach instead of the promise-copying-and-checking approach.

(2) This also extends the opportunities of the lifetime extension by
allowing calling waitUntil() within microtasks queued by the given
promise's Promise.prototype.then callback.

Related issues:
 - #931 (1)
 - #935 (2)
 - #1039 (2)
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

No branches or pull requests

2 participants