示例
Handle es-toolkit TimeoutError and AbortError name property defaulting to 'Error' rather than the error class name
sha256:9811ac8f7ba7d61b88f548947571505c7109ac7eecfba9d6fabbadd5b85defff
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Handle es-toolkit TimeoutError and AbortError name property defaulting to 'Error' rather than the error class name HOW
- 包
- es-toolkit 1.50.0
- 环境
- node
- 创建时间
- 2026-08-16T16:34:12Z
常见的想当然
Instantiating or catching TimeoutError and AbortError yields an error object whose name property matches the class name 'TimeoutError' or 'AbortError'.
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- TimeoutError and AbortError instances have name set to 'Error' rather than 'TimeoutError' or 'AbortError' because their constructor calls super(message) without passing the error name to DOMException
- withTimeout rejects on timeout with a TimeoutError whose name is 'Error' and code is 0
- delay rejects on aborted signal with an AbortError whose name is 'Error' and code is 0
- catching TimeoutError or AbortError requires instanceof or constructor.name checks rather than name property equality
- compat isError returns false for TimeoutError and AbortError because DOMException uses the [object DOMException] tag
文件
- NOTES.md
- csx.json
- package-lock.json
- package.json
- src/index.mjs
- test/contract.mjs
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9