Serviceworker: Service worker ID - remove?

Created on 16 Feb 2017  路  11Comments  路  Source: w3c/ServiceWorker

https://w3c.github.io/ServiceWorker/#dfn-service-worker-id - we don't appear to use this. Does anyone? If not we should remove it.

apr-2017-f2f

Most helpful comment

This would actually be useful if we could expose it to developers. We need something like this to correctly track upgrades and it's useful to help installing worker not mess with activating workers. Right now we need to do some things to basically fake this, but it's slow so if the browser could just provide developers with the id that it already has that would make things a bit better for developers.

All 11 comments

We might use it internally, but its probably safe to remove from the spec.

This would actually be useful if we could expose it to developers. We need something like this to correctly track upgrades and it's useful to help installing worker not mess with activating workers. Right now we need to do some things to basically fake this, but it's slow so if the browser could just provide developers with the id that it already has that would make things a bit better for developers.

We used to have the id exposed but removed it in favor of ServiceWorker object equality, if I remember correctly.

Hmm, it'd be nice if we could bring it back. There are quite a few use cases that we have for it now. Similarly there's no clean way for a specific service worker to get it's own service worker object which would also make using the id much easier.

Kind of a tangent, but if we bring this back, it would be nice to align it with Client.id. It should be possible to reference a ServiceWorker global as a Client and ideally the id value would match ServiceWorker.id.

@wanderview that'd be a change from how client ID works now, as the ID wouldn't change between termination & running the next time.

@n8schloss I've generated version IDs using hashes before - https://jakearchibald.com/sw.js. Can you talk a little bit on how an ID is better than this?

@wanderview that'd be a change from how client ID works now, as the ID wouldn't change between termination & running the next time.

Right. Good point. Carry on.

@jakearchibald, that's our current hack here. It works fine, but like @wanderview said, there's an argument to be made that having it allows for a better level of consistency between SWs and Clients. Also, if the browser is already storing an ID like this it wouldn't be much more work to expose it?

Besides that, it really would be nice to have a way for a SW to get it's own ServiceWorker object so it can tell what state it's currently in. I'll file a separate issue for that though.

F2F: We can remove this - #1077 solves the use case.

TODO: remove from spec

So there's no possibility to mention the service worker ID in log entries? :-(
My problem is, that I have lots of debug output for the SWs on the console and it's a rather difficult to identify which line was produced by which worker...

Was this page helpful?
0 / 5 - 0 ratings