diff --git a/CHANGELOG.md b/CHANGELOG.md index f4560694..6ab1bc33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added ### Changed +- Building for a Node.js that exports its bundled OpenSSL (official Node.js builds) now fails with an explicit `#error` when `` cannot be found, instead of silently compiling the OpenSSL error queue fix above out. The header ships with Node's own headers (`include/node/openssl`) and with vcpkg on Windows, so this only fires on a broken include path. Electron (BoringSSL, no OpenSSL headers or exports) and Node.js built against a shared system OpenSSL keep the header optional. Set `npm_config_node_libcurl_openssl_err=optional` to build without it anyway. ## [5.1.2] - 2026-06-08 diff --git a/binding.gyp b/binding.gyp index a3e12f0f..d1f63b83 100644 --- a/binding.gyp +++ b/binding.gyp @@ -21,7 +21,15 @@ # it for developer source builds requires the static runtime packages # (e.g. libstdc++-static on RHEL/Rocky, libstdc++-dev on Ubuntu) to be # installed, which is not a standard developer requirement. - 'node_libcurl_static_runtime%': 'false' + 'node_libcurl_static_runtime%': 'false', + # "auto": the build fails when is missing for a runtime that + # exports its bundled OpenSSL (official Node.js), because libcurl then shares + # that OpenSSL's error queue and must clear it. "optional": never fail. + 'node_libcurl_openssl_err%': 'auto', + # Normally set by the config.gypi node-gyp generates for the target runtime. + 'node_use_openssl%': 'false', + 'node_shared_openssl%': 'true', + 'built_with_electron%': 0 }, # Node 26+ (Windows): the official Node build switched to ClangCL + ThinLTO, # so common.gypi injects -flto=thin (compiler) and opt:lldltojobs=N (linker) @@ -75,6 +83,13 @@ 'NAPI_EXPERIMENTAL=1', ], 'conditions': [ + # Electron ships BoringSSL without OpenSSL headers and does not export + # OpenSSL symbols, so the addon's own OpenSSL keeps a separate queue. + ['node_libcurl_openssl_err=="auto" and node_use_openssl=="true" and node_shared_openssl=="false" and built_with_electron==0', { + 'defines': [ + 'NODE_LIBCURL_REQUIRE_OPENSSL_ERR' + ] + }], ['node_libcurl_no_setlocale=="true"', { 'defines': [ 'NODE_LIBCURL_NO_SETLOCALE' diff --git a/src/OpenSslErrorQueue.h b/src/OpenSslErrorQueue.h index eee8e660..665b36f3 100644 --- a/src/OpenSslErrorQueue.h +++ b/src/OpenSslErrorQueue.h @@ -11,6 +11,9 @@ #if __has_include() #include #define NODE_LIBCURL_HAS_OPENSSL_ERR 1 +#elif defined(NODE_LIBCURL_REQUIRE_OPENSSL_ERR) +#error \ + " not found, but this Node.js exports its bundled OpenSSL, whose error queue libcurl shares and must clear. Fix the include path, or set npm_config_node_libcurl_openssl_err=optional to build without it." #endif namespace NodeLibcurl {