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

贡献者指南