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

Samsung Internet browser throws an error when cached resources get requested #1435

Closed
Schepp opened this Issue Apr 16, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@Schepp

Schepp commented Apr 16, 2018

Library Affected:
workbox-sw 3.0.0

Browser & Platform:
Samsung Internet 6.4.10.5

Issue or Feature Request Description:
I created a Service Worker with the help of Workbox. This is the SW's source code:

https://gist.github.com/Schepp/adbc1579e8d1a38087e087a40b205322

This is the page in which context it is running:
https://templates.park.works
User: templates
PW: gera16

Upon page load, I perform a SW precaching of HTML pages, by searching all <a> elements for URLs and by prefetching them via <link rel="prefetch"> element. When idle the browser fetches these URLs and the SW then caches them in the background (see source code above).

This works well on Chrome and Safari. On Samsung Internet though, the page only works upon the first visit. Once I reload the page, or navigate to a linked page, this is what I get:

image

When I look into Samsung Internet's internet://serviceworker-internals I spot these error messages:

Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}
Console: {"lineNumber":0,"message":"The FetchEvent for \"https://templates.park.works/\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":1,"message":"Uncaught (in promise) InvalidStateError: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.","message_level":3,"sourceIdentifier":1,"sourceURL":"https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-strategies.prod.js"}

Could it have to do with the basic auth?

@jeffposnick

This comment has been minimized.

Show comment
Hide comment
@jeffposnick

jeffposnick Apr 16, 2018

Collaborator

Can you try the same code with Workbox v3.1.0?

That release includes a fix for what sounds like the underlying issue: #1392

Collaborator

jeffposnick commented Apr 16, 2018

Can you try the same code with Workbox v3.1.0?

That release includes a fix for what sounds like the underlying issue: #1392

@Schepp

This comment has been minimized.

Show comment
Hide comment
@Schepp

Schepp Apr 17, 2018

I switched it out and it worked right away. Thank you @jeffposnick!!!

Schepp commented Apr 17, 2018

I switched it out and it worked right away. Thank you @jeffposnick!!!

@Schepp Schepp closed this Apr 17, 2018

@Schepp Schepp changed the title from Samsung Internet browser throws an error when cached resources get requested to [solved] Samsung Internet browser throws an error when cached resources get requested Apr 17, 2018

@dYb

This comment has been minimized.

Show comment
Hide comment
@dYb

dYb Apr 19, 2018

@jeffposnick
Sorry but still got this problem with version 3.1.0 on samsung mobile
Library Affected:
workbox-sw 3.1.0

Browser & Platform:
Mozilla/5.0 (Linux; Android 7.0; SAMSUNG SM-G9550 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/6.4 Chrome/56.0.2924.87 Mobile Safari/537.36

Issue or Feature Request Description:
page url: https://c.m.163.com/news/b/bd_a884938fd9af4ef79267f6a8688769de_4.html
workbox config: https://gist.github.com/dYb/eb5a2b6145dd0a9be6ddfe862fcd8539

when I changed handler from staleWhileRevalidate to networkFirst, it worked right.
there is a screenshot of the error.
screenshot

dYb commented Apr 19, 2018

@jeffposnick
Sorry but still got this problem with version 3.1.0 on samsung mobile
Library Affected:
workbox-sw 3.1.0

Browser & Platform:
Mozilla/5.0 (Linux; Android 7.0; SAMSUNG SM-G9550 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/6.4 Chrome/56.0.2924.87 Mobile Safari/537.36

Issue or Feature Request Description:
page url: https://c.m.163.com/news/b/bd_a884938fd9af4ef79267f6a8688769de_4.html
workbox config: https://gist.github.com/dYb/eb5a2b6145dd0a9be6ddfe862fcd8539

when I changed handler from staleWhileRevalidate to networkFirst, it worked right.
there is a screenshot of the error.
screenshot

@Alivejke

This comment has been minimized.

Show comment
Hide comment
@Alivejke

Alivejke May 1, 2018

Same here, problem is not solved. @jeffposnick can you please reopen the issue?

Alivejke commented May 1, 2018

Same here, problem is not solved. @jeffposnick can you please reopen the issue?

@jeffposnick jeffposnick reopened this May 1, 2018

@jeffposnick jeffposnick changed the title from [solved] Samsung Internet browser throws an error when cached resources get requested to Samsung Internet browser throws an error when cached resources get requested May 1, 2018

@jeffposnick

This comment has been minimized.

Show comment
Hide comment
@jeffposnick

jeffposnick May 1, 2018

Collaborator

I managed to get chrome://inspect/ to show some underlying errors when using staleWhileRevalidate from within Samsung Internet 6.4:

screen shot 2018-05-01 at 10 51 42 am

That's a good lead and I'll investigate further.

Collaborator

jeffposnick commented May 1, 2018

I managed to get chrome://inspect/ to show some underlying errors when using staleWhileRevalidate from within Samsung Internet 6.4:

screen shot 2018-05-01 at 10 51 42 am

That's a good lead and I'll investigate further.

@jeffposnick

This comment has been minimized.

Show comment
Hide comment
@jeffposnick

jeffposnick May 1, 2018

Collaborator

Based on that, I believe that we need to update the StaleWhileRevalidate strategy in the same manner as NetworkFirst was updated in #1392

(I'll also use this as an opportunity to audit the other strategies to see if there's any other instances where event.waitUntil() might be called asynchronously.)

Collaborator

jeffposnick commented May 1, 2018

Based on that, I believe that we need to update the StaleWhileRevalidate strategy in the same manner as NetworkFirst was updated in #1392

(I'll also use this as an opportunity to audit the other strategies to see if there's any other instances where event.waitUntil() might be called asynchronously.)

@romandev

This comment has been minimized.

Show comment
Hide comment
@romandev

romandev Jun 25, 2018

@jeffposnick

Hi, I'm Jinho Bang and a Samsung Internet browser developer.

I'm here because we got reported this issue from some users. Sadly, the asynchronos waitUntil() is not implemented yet in our browser. Yes, we will implement it but our release cycle is so far. So, for a long time, we might not resolve the issue.

So, my question is whether it is possible to backport your fix to 3.1 v as well.
I'm not sure but many sites seems still using 3.1v. (e.g. globo.com)
If you could update 3.1v in CDN side, we might resolve this issue easily.

WDYT?

romandev commented Jun 25, 2018

@jeffposnick

Hi, I'm Jinho Bang and a Samsung Internet browser developer.

I'm here because we got reported this issue from some users. Sadly, the asynchronos waitUntil() is not implemented yet in our browser. Yes, we will implement it but our release cycle is so far. So, for a long time, we might not resolve the issue.

So, my question is whether it is possible to backport your fix to 3.1 v as well.
I'm not sure but many sites seems still using 3.1v. (e.g. globo.com)
If you could update 3.1v in CDN side, we might resolve this issue easily.

WDYT?

@romandev

This comment has been minimized.

Show comment
Hide comment
@romandev

romandev commented Jun 26, 2018

@jeffposnick Gentle ping :)

@jeffposnick

This comment has been minimized.

Show comment
Hide comment
@jeffposnick

jeffposnick Jun 26, 2018

Collaborator

Hello @romandev—Our policy is not to do post-release changes without bumping a version number, following general semantic versioning principles.

And in any case, due to the way that importScripts() is aggressively cached, it's not likely that any changes would actually get propagated out to existing users—you really need to update the URL to ensure that imported scripts are retrieved again.

It's up to developers to manage their dependencies on Workbox and update as they see fit. I know that's frustrating when there's a bug fix that a developer is missing out on, but encouraging that developer to upgrade is the only course of action.

Collaborator

jeffposnick commented Jun 26, 2018

Hello @romandev—Our policy is not to do post-release changes without bumping a version number, following general semantic versioning principles.

And in any case, due to the way that importScripts() is aggressively cached, it's not likely that any changes would actually get propagated out to existing users—you really need to update the URL to ensure that imported scripts are retrieved again.

It's up to developers to manage their dependencies on Workbox and update as they see fit. I know that's frustrating when there's a bug fix that a developer is missing out on, but encouraging that developer to upgrade is the only course of action.

@romandev

This comment has been minimized.

Show comment
Hide comment
@romandev

romandev Jun 28, 2018

@jeffposnick,

Looks reasonable to me. Thank you for detailed explanation. :)

romandev commented Jun 28, 2018

@jeffposnick,

Looks reasonable to me. Thank you for detailed explanation. :)

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