Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a developer-provided name #1121

Closed
domenic opened this issue Apr 17, 2017 · 7 comments
Closed

Adding a developer-provided name #1121

domenic opened this issue Apr 17, 2017 · 7 comments

Comments

@domenic
Copy link
Contributor

domenic commented Apr 17, 2017

This is a spinoff of whatwg/html#2477 designed specifically to gather feedback from the service worker community.

There we're contemplating adding a web-dev-supplied name:

const w = new Worker(url, { name });
w.name

// inside worker
self.name

This is anticipated to mostly be used by devtools.

Service workers have an id, but I guess that isn't developer-exposed, and is slated to be removed? #1076

For service workers a name seems less important since there's only going to be one per page (right?) and they're pretty identifiable already by their scope. So maybe we should do nothing for service workers? On the other hand @n8schloss mentioned in #1076 (comment) that this might be useful for certain use cases.

I guess there's also a bunch of questions about id and clients there that I don't understand.

I'd like some clarity on which path we want to take. Here are the options I see:

  • Add name to workers and omit it from service workers as they are already distinguishable in the debugger.
  • Add name to workers and service workers as a developer-helper, but with no tie to service-worker concepts like clients or IDs
  • Wait and see if we can figure out a story for service worker IDs/clients and then copy that over to workers.
@wanderview
Copy link
Member

Yea, internally we actually use the same field for SharedWorker's name and ServiceWorker scope.

@n8schloss
Copy link

n8schloss commented Apr 17, 2017

id is useful when it's tied to a specific instance of a service worker, so the currently installing service worker could have one id while the currently activating service worker could have another.

@domenic are you thinking that name would be shared across all instances of the same serviceworker, or will each instance be able to have it's own name?

@domenic
Copy link
Contributor Author

domenic commented Apr 17, 2017

I don't really have enough clue about service worker lifetimes to know what would be a reasonable answer there.

@jungkees
Copy link
Collaborator

jungkees commented Apr 18, 2017

As far as I understood, what whatwg/html#2477 suggests is to give a name to a worker global scope basically. I think we'd need to consider two more aspects when it comes to SW:

  1. A SW's name can't be assigned by devs. It should be something UA would assign instead.
  2. The service worker struct instance to the ServiceWorkerGlobalScope instance can be 1 to N relationship. A cold start of a service worker creates a new ServiceWorkerGlobalScope object.

That said, I don't think the name for debugging is much relevant to SW case. As @n8schloss suggests, if we need an id for debugging, exposing service worker's id as ServiceWorker.id would be nice. ServiceWorker.id + ServiceWorker.state can identify a certain service worker in the platform I think.

EDIT: ServiceWorker.id alone would identify a service worker indeed.

@domenic
Copy link
Contributor Author

domenic commented Apr 18, 2017

Hmm OK. This makes me lean toward "Add name to workers and omit it from service workers as they are already distinguishable in the debugger [and the concept doesn't make as much sense for them]."

@jungkees
Copy link
Collaborator

Checking whatwg/html#2664, I think we can close this issue?

@domenic
Copy link
Contributor Author

domenic commented May 15, 2017

Yep, sounds good!

@domenic domenic closed this as completed May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants