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

Racing e.respondWith(p) #302

Closed
jungkees opened this issue Jun 2, 2014 · 6 comments
Closed

Racing e.respondWith(p) #302

jungkees opened this issue Jun 2, 2014 · 6 comments

Comments

@jungkees
Copy link
Collaborator

jungkees commented Jun 2, 2014

History: #184

It seems ignoring the subsequent calls does not mean exactly the same thing as allowing racing. If we allow racing among multiple e.respondWith(p) calls, we need to determine whether the first fulfillment will win or the first settlement will win (including p's rejection). Seems it'd be a little magic if we wait for the first fulfillment, though.

And, do we want to allow racing across multiple event handlers?

this.addEventListener("fetch", function(e) {
  e.respondWith(p1);
  e.respondWith(p2);
});

this.addEventListener("fetch", function(e) {
  e.respondWith(p3);
});

In any case above, if we allow racing, multiple e.default() calls running in parallel should be allowed as well, I suppose.

@annevk
Copy link
Member

annevk commented Jun 2, 2014

First settlement. default() should always do the same, so I'm not sure racing makes sense there.

@michael-nordman
Copy link
Collaborator

I'm not sure racing makes sense at all. Seems like the caller can provide a promise, then conduct whatever race it'd like and resolve the promise with the winner.

I think the multiple event handlers case argues against racing. Suppose that is happening unbeknownst to the authors of the two different event handlers. Nice tricky flaky bug to track down.

Is e.default() a promise or a special response type that indicates 'please just use the network'?

@jungkees
Copy link
Collaborator Author

jungkees commented Jun 3, 2014

Is e.default() a promise or a special response type that indicates 'please just use the network'?

e.default() is a promise resolves to a response object (AbstractResponse).

@jakearchibald
Copy link
Contributor

I agree with @michael-nordman, I think we should throw on a second call to respondWith.

If you want racing, you have to code it yourself.

@jakearchibald
Copy link
Contributor

Yep, we throw on 2nd respondWith #51 (comment)

@KenjiBaheux
Copy link
Collaborator

Tracked at crbug.com/410699 for Blink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants