Repository navigation
NixOS 上 HMR 服务报 --expose-internals is required: node-addon-require-builtin 探测在 Nix 编译的 Node 上失败 #690
Replies: 8 comments 15 replies
|
大佬辛苦了!感谢,我也遇到同样的问题了。 |
|
我在 macos arm64 上使用 nixpkgs 提供的 nodejs 也会有这个问题,而且
# .envrc file
eval "$(fnm env --shell bash)"
fnm use 26 >/dev/null最后可以在 |
|
非常感谢您的回复,不过因为我对这个harness保持悲观我现在已经弃用了😮💨 |
|
Hi all - for me, my Node install is via home-manager and I have npm global installs and |
|
I'm begging you guys, this project is supposed to be different and go against their V8 request headers. They have no intention of fixing this issue at all - they just want the community to work together and merge PRs. I advise you to get rid of this stuff from your production environment as soon as possible. If you think it's worth the trouble for a toy project, then I have nothing to say. But if you want to use it for real work, I strongly advise you to give up on that idea |
|
Same root cause, one more data point — and since 0.1.6+ it is fatal at boot for every profile, not just HMR:
So from 0.1.6 on, every profile boot hard-requires the memory-scanning getter, which does not recognize Nix-built (or Electron-built, per #752) Node binaries regardless of version. Until the scanner learns those builds or the interception degrades gracefully (#7710), dsh ≥ 0.1.6 is unbootable on Nix-built Node. |
同一根因的 macOS + Nix 复现:Node 由 Nix 源码构建时,addon 探测失败在 0.2.0-rc.2 里已经变成致命崩溃我在 macOS arm64 上命中了同一个根因,但报错形态比 #690 / #113 / #752 更彻底 —— 不是降级告警,而是 boot 阶段直接崩溃:
与 #690 的关键一致性:唯一的变量是 Node 的构建渠道#690 用 x64 Linux 做了官方预编译 vs Nix 源码编译的对照。我在 macOS arm64 上复现了同一结论,同一个 addon、同一个 Node 版本号、同一台机器:
版本号、platform、arch、napi-v9、 精确根因:nixpkgs 强制注入的叶子帧指针,与 addon 的字节匹配器冲突打开 addon 自带的 字段偏移(0x1c8)和语义完全一致,只是 nixpkgs 的编译参数让编译器给这个 getter 生成了栈帧前后导。我已用最小 C 复现逐字节确认了成因:nixpkgs 的 addon 的 arm64 解析器只接受 也就是说:这不是"Node 版本不兼容",而是"字节模式匹配对构建参数过于敏感" —— 任何非官方构建(发行版、自编译、不同优化/加固参数)都可能命中。 nixpkgs 侧已在跟踪nixpkgs 已有同问题 issue(NixOS/nixpkgs#565667,nodejs 维护者在跟进)。但请注意:nixpkgs 全局关闭帧指针会波及所有依赖(原报告者实测触发 ffmpeg/blender 等大规模重建),因此不应期待 nixpkgs 为单个消费者回退这个刻意保留的默认值。 这也意味着 dsh 侧的降级路径不是"可选项",而是这个问题唯一现实的修复位置。 不是版本问题:你机器上任何 Node 都救不了我逐个测了本机 8 个 Nix 构建的 Node(见文末证据),全部失败: 所以「换 Node 版本」这条常规排查路径在这里完全无效,用户会一直在原地打转 —— 这正是 #113 / #690 / #752 三个帖子在两天内爆发的原因。 补充材料:
|
|
Root cause on Linux x86-64, at byte level: it is not "Nix's V8 layout differs". The getter is in the right place and is exported; the addon's instruction matcher rejects it because nixpkgs compiles Node with Evidence
The symbol Those two bytes come from
Why
|
Uh oh!
There was an error while loading. Please reload this page.
问题
NixOS 26.05 (x86_64) 上运行
dsh web或dsh --profile cc-tui启动即失败:对 cc-tui profile 还附带
Cannot find package 'dsh-cc-tui'/dsh-session-persistence-sqlite/dsh-working-activity的 ERR_MODULE_NOT_FOUND(loader.internal 为 null 时 bundle 包解析走错路径)。加
--expose-internals后一切正常(TUI 已实测可渲染)。根因定位
cordis-plugin-loader获取 Node 内部 ESM loader 有两条路径:process.execArgv含--expose-internals时直接 requirenode-addon-require-builtin(v0.1.4) 原生 addon 运行时探测路径 2 在 Nix 编译的 Node 上失败:
关键对照实验(排除平台/版本因素)
同一 addon、同一 Node 版本号、同一架构(x86_64 Linux):差异只来自 Nix 从源码构建与官方预编译构建的 V8 内部布局不同,addon 的运行时探测(node-addon-native-custom-loader)认不出 Nix 构建的 getter 布局。Windows(官方 MSVC 预编译 24.15/24.16)不受影响。
环境
建议
node-addon-require-builtin0.1.4 的探测逻辑对 Nix/源码构建 Node 的兼容性(或更新版本);--expose-internals(当前信息误导用户以为是启动参数问题);--expose-internals启动。All reactions