Intent to Implement and Ship: ‘name’ attribute for dedicated workers

103 views
Skip to first unread message

Asami Doi

unread,
Aug 20, 2018, 2:27:01 PM8/20/18
to blin...@chromium.org, worke...@chromium.org, nhi...@chromium.org

Contact emails

Impl: asam...@google.com, nhi...@chromium.org


Explainer / Summary

This feature allows specifying the worker’s name via an optional argument on the constructor. You can distinguish dedicated workers by the name when you have multiple workers with the same URL. Developers can print ‘name’ in dev tools console which will make it easier to debug workers. See discussion at https://github.com/whatwg/html/issues/2477 .


The ‘name’ param in WorkerOptions enables to set worker’s name.


const worker = new Worker(‘worker.js’, { name: ‘worker-name’ });


A worker can access its name by ‘self.name’.


// worker.js

console.log(self.name); // worker_name


When the ‘name’ param is omitted, an empty string is used as the default value.


Spec

‘name’ attribute in WorkerOptions dictionary:

https://html.spec.whatwg.org/multipage/workers.html#workeroptions


‘name’ attribute in DedicatedWorkerGlobalScope interface:

https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface


Tag review process is skipped because this feature has already been supported by 2 browsers.


Link to Origin Trial feedback summary

N/A


Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes.


Demo link

N/A


Debuggability

  • Web developers can display the dedicated worker’s name on their console.

  • There is a possible DevTools displays dedicated worker’s name in the inspect page in the future.


Risks

Interoperability and Compatibility

Low.


Ergonomics

> Are there any other platform APIs this feature will frequently be used in tandem with?

> Could the default usage of this API make it hard for Chrome to maintain good performance (i.e. synchronous return, must run on a certain thread, guaranteed return timing)?


No.


Activation

Easy: Developers just put in name property when they initialize a dedicated worker. Also, they can access it by ‘self.name’.


Is this feature fully tested by web-platform-tests? Link to test suite results from wpt.fyi.

Yes (https://wpt.fyi/results/workers/name-property.html)


Entry on the feature dashboard

https://www.chromestatus.com/feature/4594144336936960


Alex Russell

unread,
Aug 21, 2018, 12:35:59 PM8/21/18
to blink-dev, worke...@chromium.org, nhi...@chromium.org
LGTM1

Yoav Weiss

unread,
Aug 21, 2018, 3:27:05 PM8/21/18
to Alex Russell, blink-dev, worke...@chromium.org, nhi...@chromium.org
LGTM2

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97c20838-adae-4e7b-9652-1fa79a48fe5c%40chromium.org.

Chris Harrelson

unread,
Aug 21, 2018, 5:49:28 PM8/21/18
to Yoav Weiss, Alex Russell, blink-dev, worke...@chromium.org, Hiroki Nakagawa
Reply all
Reply to author
Forward
0 new messages