Closed Bug 1174078 Opened 9 years ago Closed 9 years ago

Calling "fetch" inside Service Worker's "onfetch" handler in b2g causes "onfetch" again that leads to an infinite loop

Categories

(Core :: DOM: Service Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
FxOS-S1 (26Jun)
Tracking Status
firefox41 --- fixed

People

(Reporter: azasypkin, Assigned: ferjm)

References

Details

Attachments

(2 files, 1 obsolete file)

STR:

1. Install [1] as preinstalled app (to workaround bug 1173539);
2. Run it and make sure that service worker is registered;
3. Kill app with Task Manager and run again;
4. Observe log - there is infinite loop that infinitely requests first resource in the app index.html - app.css. 

Flame PVT mc Engineering Build:

Build Identifier: 20150611010205
Git Commit Info: 2015-06-11 18:43:32, 4219419a

[1] https://github.com/azasypkin/sw-tests/tree/master/fxos-app
Whiteboard: [s4]
Status: NEW → ASSIGNED
Target Milestone: --- → NGA S3 (26Jun)
Is this an issue with intercepting the app: protocol?
(In reply to Ben Kelly [:bkelly] from comment #1)
> Is this an issue with intercepting the app: protocol?

I was able to reproduce it only with app:// protocol on b2g. I tried to run app in b2g browser [1], but service worker registration was always failing for me at that time, so I just gave up.

[1] http://azasypkin.github.io/sw-tests/fxos-app/
Attached patch v1Splinter Review
I'll be adding a new test on another patch
Attachment #8622374 - Flags: review?(nsm.nikhil)
(In reply to Ben Kelly [:bkelly] from comment #1)
> Is this an issue with intercepting the app: protocol?

Yes, this is only happening with the app:// protocol.
Whiteboard: [s4]
Attached patch Test (obsolete) — Splinter Review
Attachment #8622404 - Flags: review?(nsm.nikhil)
Comment on attachment 8622374 [details] [diff] [review]
v1

Review of attachment 8622374 [details] [diff] [review]:
-----------------------------------------------------------------

::: netwerk/protocol/app/AppProtocolHandler.cpp
@@ +297,5 @@
>  }
>  
> +NS_IMETHODIMP DummyChannel::ForceNoIntercept()
> +{
> +  return NS_OK;

return NS_ERROR_NOT_IMPLEMENTED?
Attachment #8622374 - Flags: review?(nsm.nikhil) → review+
Comment on attachment 8622404 [details] [diff] [review]
Test

Review of attachment 8622404 [details] [diff] [review]:
-----------------------------------------------------------------

I'd like to see the new patch.

::: dom/workers/test/serviceworkers/app-protocol/sw.js
@@ +22,5 @@
> +    var results = regex.exec(event.request.url);
> +    return results === null ?
> +                       ''   :
> +                       decodeURIComponent(results[1].replace(/\+/g, ' '));
> +  }

Please use the URL and URLSearchParams interfaces instead of manual regexp parsing.
Attachment #8622404 - Flags: review?(nsm.nikhil)
Attached patch TestSplinter Review
Attachment #8622404 - Attachment is obsolete: true
Attachment #8622953 - Flags: review?(nsm.nikhil)
Blocks: 1172902
Comment on attachment 8622953 [details] [diff] [review]
Test

Review of attachment 8622953 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/workers/test/serviceworkers/app-protocol/sw.js
@@ +16,5 @@
>  });
>  
>  self.addEventListener('fetch', (event) => {
>    if (event.request.url.indexOf('foo.txt') >= 0) {
> +    var searchParams = new URLSearchParams(event.request.url.split("?")[1]);

var searchParams = new URLSearchParams(new URL(event.request.url));
Attachment #8622953 - Flags: review?(nsm.nikhil) → review+
https://hg.mozilla.org/mozilla-central/rev/e8d2c117e4b1
https://hg.mozilla.org/mozilla-central/rev/9ea2dfc3325d
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
checked in today's m-c build (6/18) with Flame device and it works as expected. Thanks for fixing it so quickly!
Blocks: 1175944
As NGA Program Manager suggested, let's replace the NGA-X milestones with FxOS-Sx ones (more generic ones), once Bug 1174794 has already landed
Target Milestone: NGA S3 (26Jun) → FxOS-S1 (26Jun)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: