mdn/content

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

Open

#35,064 建立於 2024年7月25日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Markdown (22,427 fork)batch import
Content:WebAPIarea: Workershelp wanted

倉庫指標

Star
 (8,900 star)
PR 合併指標
 (平均合併 7天 3小時) (30 天內合併 147 個 PR)

描述

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

貢獻者指南