From afab2513765626cb3dde7c7ca4708b5d9c837644 Mon Sep 17 00:00:00 2001 From: Adrien Beraud Date: Tue, 27 Oct 2026 22:59:16 -0400 Subject: [PATCH] nodejs: isolate native Linux dependency symbols Use RTLD_DEEPBIND when loading the Linux addon so its llhttp calls do not resolve to Node's incompatible bundled parser. The CI image uses llhttp 9.2.1 while Node 22 exports 9.4.3, corrupting the heap when the proxy client starts. Preserve default loading on other platforms. --- nodejs/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nodejs/index.js b/nodejs/index.js index 11ed0e6e..6980d3be 100644 --- a/nodejs/index.js +++ b/nodejs/index.js @@ -1,10 +1,15 @@ import { EventEmitter } from 'node:events'; +import { constants } from 'node:os'; import { dlopen } from 'node:process'; import load from 'node-gyp-build'; import createCrypto from './crypto.js'; const binding = { exports: {} }; -dlopen(binding, process.env.OPENDHT_NODE_BINDING || load.path(import.meta.dirname)); +const flags = process.platform === 'linux' + ? constants.dlopen.RTLD_LAZY | constants.dlopen.RTLD_DEEPBIND + : undefined; +dlopen(binding, process.env.OPENDHT_NODE_BINDING || load.path(import.meta.dirname), + flags); const native = binding.exports; const { PublicKey, PrivateKey, Certificate, Identity, handle } = createCrypto(native);