Re: [ServiceWorker] Errors inside Promises are not thrown (#600)

You need to use .catch(function (err) { /* use the error */ }) to catch promise errors.

From: Boopathi Rajaa [mailto:notifications@github.com]
Sent: Tuesday, January 13, 2015 01:15
To: slightlyoff/ServiceWorker
Subject: [ServiceWorker] Promises inside Service workers don't throw errors (#600)


Also, reported this bug here, https://code.google.com/p/chromium/issues/detail?id=448281

this.addEventListener('install', function(event) {

    event.waitUntil(

        caches

            .open('demo')

            .then(function() {

                throw new Error('Blah Blah');

            })

    );

});

doesn't throw the error. It is being caught somewhere.

Also, whenever this error happens, the service worker is registered and immediately unregistered. And when refreshing the page, a new worker with an incremented version ID is registered and the same happens because of the error, and this error is never thrown.

[screenshot 2015-01-13 11 28 55]<https://cloud.githubusercontent.com/assets/294474/5716701/8839d19a-9b19-11e4-8628-f1705c1a6fa3.png>
[screenshot 2015-01-13 11 29 15]<https://cloud.githubusercontent.com/assets/294474/5716700/8837498e-9b19-11e4-92e0-7cfaa1e28c8e.png>

—
Reply to this email directly or view it on GitHub<https://github.com/slightlyoff/ServiceWorker/issues/600>.


---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/600#issuecomment-69700700

Received on Tuesday, 13 January 2015 06:23:40 UTC