messageerror
The messageerror event is fired on a DedicatedWorkerGlobalScope object when it receives a message that can't be deserialized.
This event is not cancellable and does not bubble.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 60 | 18 | 57 | 16.4 | 60 | 16.4 | |
| The messageerror event is fired on a MessagePort object when it receives a message that can't be deserialized. | 60 | 18 | 57 | 16.4 | 60 | 16.4 |
| The messageerror event is fired to the ServiceWorkerContainer when an incoming message sent to the associated worker can't be deserialized. | 80 | 80 | 65 | 16.4 | 80 | 16.4 |
| The messageerror event of the ServiceWorkerGlobalScope interface occurs when incoming messages can't be deserialized. | 81 | 81 | 65 | 11.1 | 81 | 11.3 |
| The messageerror event is fired on a Window object when it receives a message that can't be deserialized. | 60 | 18 | 57 | 16.4 | 60 | 16.4 |
| The messageerror event is fired on a Worker object when it receives a message that can't be deserialized. | | 18 | 57 | 16.4 | | 16.4 |
- This feature was removed in a later browser version (79)
- This browser only partially implements this feature
- This feature was removed in a later browser version (16.4)
- Although the `onmessageerror` event handler property is supported, the `messageerror` event is never fired.
- This browser only partially implements this feature
- This feature was removed in a later browser version (16.4)
- Although the `onmessageerror` event handler property is supported, the `messageerror` event is never fired.
- This browser only partially implements this feature
- Although the `onmessageerror` property is supported, the `messageerror` event is never fired. See bug 272967.
- This browser only partially implements this feature
- Although the `onmessageerror` property is supported, the `messageerror` event is never fired. See bug 272967.
- This feature was removed in a later browser version (79)
Syntax
// worker.js
self.addEventListener("messageerror", (event) => {
self.postMessage("Error receiving message");
console.error(event);
}); Use cases
-
Using messageerror
The messageerror event is fired on a DedicatedWorkerGlobalScope object when it receives a message that can't be deserialized.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.