Re: [w3c/push-api] Rewrite .subscribe() to fix various bugs (PR #350)

@marcoscaceres commented on this pull request.



> +            <li>If |subscription| is an error, [=queue a global task=] on the [=networking task
+            source=] using |global| to [=reject=] |promise| with an {{"AbortError"}}
+            {{DOMException}} and terminate these steps.

> How can subscription be an error here? 

You are right. It can't be an error. 

> The outcome of an attempt to retrieve it might return an error, but the subscription will be a subscription, right?

Right. In fact, so long as [=create a push subscription=] succeeded previously, there is _always_ a subscription. 

The problem (question?) is actually in [=create a push subscription=]: can [=create a push subscription=] result in an exception? 

It appears it can for a variety of reasons (e.g., [Gecko binding layer](https://searchfox.org/mozilla-central/source/__GENERATED__/dom/bindings/PushManagerBinding.cpp#1637) generates a bunch, [WebKit](https://webkit-search.igalia.com/webkit/source/Source/WebCore/workers/service/ServiceWorkerContainer.cpp#573)).

So, I think the right thing to do here is basically say, if creating [=create a push subscription=] results in an exception, reject the promise with it. 

I'll also update [=create a push subscription=] so it "tries" to create the push subscription and re-throws any exceptions.

 
 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/pull/350#discussion_r902180422
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/push-api/pull/350/review/1012987955@github.com>

Received on Tuesday, 21 June 2022 05:39:00 UTC