Implementations are missing navigator.serviceWorker in workers
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
Hi!
I am doing some exploration into Web Workers and Service Workers and the communication mechanism between them.
I was expecting inside DedicatedWorkerGlobalScope -> WorkerNavigator there to be the seviceWorker property for the ServiceWorkerContainer.
// Inside web-worker.js
async function postMessageToServiceWorker() {
const reg = await self.navigator.serviceWorker.getRegistration(); // <-- throws exception, 'serviceWorker' undefined
reg.active.postMessage({ some: 'message' });
}
According to the spec, I think this is supposed to be populated? But I haven't found a clear answer one way or another.

Is this just a browser compatibility bug? Is there a clear answer to whether or not the ServiceWorkerContainer is supposed to be available in Web Workers?
I tried testing in Chromium Edge, Chrome, and Firefox latest.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the linked ServiceWorker specification and the reported behavior in DedicatedWorkerGlobalScope and WorkerNavigator; reproduce the navigator.serviceWorker lookup in Chromium Edge, Chrome, and Firefox. Done means establishing whether the property is specified and implemented, then recording the compatibility or specification conclusion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100