mdn/content

Improve `messageerror` example to show a case in which the event is fired

Open

#35.064 aperta il 25 lug 2024

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Markdown (22.427 fork)batch import
Content:WebAPIarea: Workershelp wanted

Metriche repository

Star
 (8900 star)
Metriche merge PR
 (Merge medio 7g 3h) (147 PR mergiate in 30 g)

Descrizione

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Worker/messageerror_event

What specific section or headline is this issue about?

Example

What information was incorrect, unhelpful, or incomplete?

I was trying to figure out what code can cause a messageerror event, and after failing to figure it out by myself I decided to go read on MDN.

Unfortunately MDN is very vague: it says that the error is fired when something cannot be deserialized, but it does not actually say in which case something can fail being deserialized.

What did you expect to see?

The example should have to different threads:

  • the main thread postMessages something to the worker thread
  • the worker thread fails to deserialize it and fires the messageerror event

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

Guida contributor