No adapter implements napi_add_env_cleanup_hook, forcing per-environment native state to be process-global
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 50/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- cpp, javascript
调研方向
首先,将 Node-API 适配器文件 js_native_api_chakra.cc、js_native_api_javascriptcore.cc、js_native_api_quickjs.cc 和 js_native_api_v8.cc 与 napi-inl.h 中 Env::AddCleanupHook 的使用进行比较。然后检查 Polyfills/URL/Source/URL.cpp 和 Polyfills/URL/Include/Babylon/Polyfills/URL.h;完成的标准是所有适配器都支持清理钩子,并且 blob URL 存储按环境限定作用域并在每个环境中完成清理。
由索引模型根据 Issue 内容生成。
描述
Summary
There is no portable way to run native cleanup when a JS environment is torn down, because no Node-API adapter in Core/Node-API/Source implements napi_add_env_cleanup_hook:
$ grep -rn "napi_add_env_cleanup_hook" Core/Node-API/Source
(no matches)
The only reference anywhere in the repo is the vendored node-addon-api header Core/Node-API/Include/Shared/napi/napi-inl.h, which calls it from Napi::Env::AddCleanupHook. That call has no implementation behind it in js_native_api_chakra.cc, js_native_api_javascriptcore.cc, js_native_api_quickjs.cc or js_native_api_v8.cc.
Impact
Native polyfill state that logically belongs to an environment has to be made process-global instead, and then leaks for the life of the process.
The concrete case is the blob URL store added in #207 (Polyfills/URL/Source/URL.cpp). URL.createObjectURL registers an entry that is normally released by URL.revokeObjectURL. Entries that are never revoked should be released when the environment goes away -- that is what a browser does at unload. With no teardown hook the store must be process-global, so an embedder that creates and destroys environments over the process lifetime accumulates every un-revoked blob URL, and the buffers behind them, until the process exits.
Polyfills/URL/Include/Babylon/Polyfills/URL.h documents the store as process-global for exactly this reason, and RegisterObjectURL/RevokeObjectURL already take a Napi::Env that is currently unused, kept for future per-env scoping.
Suggested fix
Implement napi_add_env_cleanup_hook and napi_remove_env_cleanup_hook in the adapters, then scope the blob URL store per environment and drop its entries from the cleanup hook.
Notes
Not covered by the existing issues: #194 was the JSC napi_typeof bug, #213 was the UrlLib blob: scheme resolver (implemented in #207), and #214 is the UrlLib Apple lifetime bug.
- 主要语言
- C++
- 星标
- 22
- 派生
- 23
- 平均合并
- 6 小时 17 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
BabylonJS/JsRuntimeHost 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
BabylonJS/JsRuntimeHost#234 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
BabylonJS/JsRuntimeHost#173 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
BabylonJS/JsRuntimeHost#241 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
BabylonJS/JsRuntimeHost#228 ·
维护者通常 1 天内回复
-
napi_unwrap does not reject objects that were never wrapped (V8 port faults, QuickJS port confuses types)可能已有人在做 @bghgary 于 58 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 68/100
BabylonJS/JsRuntimeHost#226 ·
维护者通常 1 天内回复
查看 BabylonJS/JsRuntimeHost 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
维护者通常 1 天内回复
-
(S1 - Need confirmation)
难度 2/5 1-3 小时 新手友好度 65/100
CleverRaven/Cataclysm-DDA#89159 ·
维护者通常 1 天内回复
-
area:libnvmpi bug P3
难度 2/5 1-3 小时 新手友好度 78/100
gjrtimmer/jetson-nvmpi#33 ·
-
bug(wasi_crypto): ArrayOutput::pull reports the wrong all-pulled flag可能已有人在做 @Yashbhu 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 1 天内回复
-
bug question
难度 1/5 1 小时以内 新手友好度 62/100