百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
返回工具页/返回 Issues 列表
#3482·ava

(严重级别并发错误): 在测试超时或不活动期间调用双重卸载(`t.teardown()`)

作者: codeCraft-Ritik创建于 2026年9月15日更新于 2026年9月29日
标签needs triage

In lib/test.js, when a test returns a Promise/Observable and encounters a timeout (this.finishDueToTimeout()) or inactivity (this.finishDueToInactivity()), resolve(this.finish()) is immediately invoked. This executes this.finish(), running all teardowns registered via t.teardown().

However, the test's user-provided asynchronous function continues running in the background. When that promise eventually settles (resolves or rejects) at a later time, its .then(() => resolve(this.finish())) handler executes this.finish() a second time.

Because finish() does not check if it has already completed, and this.teardowns is not cleared after execution, this.runTeardowns() iterates over all teardowns again. Any non-idempotent teardown hook (e.g. server.close(), db.disconnect(), removing temp directories, or closing file handles) throws double-free errors, causing unhandled rejections or crashes.

内容来源: avajs/ava

查看 GitHub 原文在 GitHub 查看讨论