Open
Bug 1156830
Opened 10 years ago
Updated 2 years ago
Message sent from service worker sometimes is not received by the client
Categories
(Core :: DOM: Workers, defect, P5)
Core
DOM: Workers
Tracking
()
NEW
People
(Reporter: ferjm, Unassigned)
References
Details
With the test case from [1] a message sent from a service worker via client.postMessage is sometimes not received on the client.
STR on Nightly:
1. Go to [1]
2. Reload the page
3. Restart the browser
4. Go to [1]
Expected 5. You should see this on the browser console: "MESSAGE RECEIVED" "using client before receiving message"
Actual 5. You don't see that log. Reloading the page should show it.
STR on B2G:
1. Open the Gaia Browser app.
2. Go to [1]
3. Reload the page.
4. Kill and start the Browser app.
Expected 5. You should see this on the logcat: "MESSAGE RECEIVED" "using client before receiving message"
Actual 5. You don't see that log.
[1] https://github.com/ferjm/swpostmessage
Updated•10 years ago
|
Flags: needinfo?(nsm.nikhil)
Comment 1•10 years ago
|
||
So there are two fetch events being dispatched when refreshing the page after the worker has been registered.
1. onfetch index.html: client() rejects because matchAll() resolves to an empty list. This correct since we don't have a document at this point.
2. onfetch test.html: client() resolves to a client and postMessage dispatches an event on navigator.serviceWorker. However, the onmessage handler is set in test.html which might not have been loaded by the time the event is dispatched.
At this point, _client was assigned, but refreshing the page should result in a different service worker client, which is not linked to _client. Thus, after the page is reloaded a second time, _client.postMessage should have no effect.
Clearing ni? since catalin answered.
Fernando, it would be good to know what you are trying to achieve. If there is a use-case where the SW should post a message to the page that it is currently loading, we should file spec bugs to discuss it.
Flags: needinfo?(nsm.nikhil)
Comment 3•10 years ago
|
||
Just to be clear, I think the bug in the example is that messages are dispatched to the window after multiple refreshes, when _client should reference a previous "service worker client".
This happens because, in gecko, a client object is linked to the outer window of a service worker client, which doesn't change on navigation/refresh. I've filed bug 1158728.
Updated•7 years ago
|
Priority: -- → P5
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•