The onerror property of the WorkerGlobalScope interface represents an EventHandler to be called when the error event occurs and bubbles through the Worker.


self.onerror = function() { ... };


The following code snippet shows an onerror handler set inside a worker:

self.onerror = function() {
  console.log('There is an error inside your worker!');


Specification Status Comment
HTML Living Standard
The definition of 'WorkerGlobalScope.onerror' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support4 ?3.5 Yes11.54
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support ?40 ?4 Yes5.14.0

See also

The WorkerGlobalScope interface it belongs to.

Document Tags and Contributors

Contributors to this page: fscholz, teoli, chrisdavidmills, kscarfone
Last updated by: fscholz,