Closed
Bug 1416671
Opened 7 years ago
Closed 7 years ago
registration.active, .installing, and .waiting are always null inside Service Worker
Categories
(Core :: DOM: Service Workers, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1113522
People
(Reporter: dan, Unassigned)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36
Steps to reproduce:
Use this service worker:
addEventListener('fetch', fetchEvent => {
console.log('registration.active', registration.active);
});
Actual results:
console logs "registration.active null"
Expected results:
registration.active should not be null; it should return a reference to the currently active Service Worker.
registration.active is correctly not null in Chrome 62. (We know that there must be an active Service Worker here in a fetch event listener; otherwise, we wouldn't be getting called.)
registration.active is perhaps the least useful property of the registration object, but registration.waiting and registration.installing are also always null, even when there are installing/waiting Service Workers. That matters because it means that we can't communicate with waiting Service Workers from inside the worker (e.g. to post it a message asking it to skipWaiting)
Comment 1•7 years ago
|
||
Hi Dan, any chance you could provide a simple comprehensive test case (not just snippet) to reproduce your issue? That helps us investigate. Thanks.
Flags: needinfo?(dan)
| Reporter | ||
Comment 2•7 years ago
|
||
Flags: needinfo?(dan)
| Reporter | ||
Comment 3•7 years ago
|
||
| Reporter | ||
Comment 4•7 years ago
|
||
I don't know if I'm supposed to write this in some kind of test harness or something. The SW "snippet" is in fact the entire SW file; the HTML file is a basic file that just registers the service worker.
<!DOCTYPE html><html><head><meta charset="utf-8"><title>bug 1416671</title></head>
<body>
<script>navigator.serviceWorker.register('sw.js');</script>
</body></html>
Open that up in a simple HTTP server, e.g. `python -m SimpleHTTPServer` and open http://localhost:8000/index.html in Firefox. The console will log "registration.active null" but it should not be null.
Comment 5•7 years ago
|
||
Thanks for the test case, Dan. (OT: I enjoyed your https://redfin.engineering/i-watched-all-of-the-chrome-dev-summit-2017-videos-so-you-dont-have-to-9b62a593c3cb :)
Andrew Sutherland can tell us what's going on here.
Flags: needinfo?(bugmail)
Comment 6•7 years ago
|
||
This is bug 1113522. We currently hardcode a return of nullptr for all of the ServiceWorkerRegistrationWorkerThread::Get*() methods. I believe the plan is to wait for :bkelly's Clients refactor to land (which is currently landing, woooo!).
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(bugmail)
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•