Skip to content

Commit ce12d9e

Browse files
authored
fix: do not crash if Node.js is compiled without SSL (#4727)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent ebe3e33 commit ce12d9e

2 files changed

Lines changed: 75 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
runs-on: ${{ matrix.runs-on }}
8686
no-wasm-simd: '1'
8787
secrets: inherit
88-
88+
8989
test-without-intl:
9090
name: Test with Node.js ${{ matrix.node-version }} compiled --without-intl
9191
strategy:
@@ -172,6 +172,79 @@ jobs:
172172
- name: Run tests
173173
run: npm run test:javascript:without-intl
174174

175+
test-without-ssl:
176+
name: Test with Node.js ${{ matrix.node-version }} compiled --without-ssl
177+
strategy:
178+
fail-fast: false
179+
max-parallel: 0
180+
matrix:
181+
node-version: ['20', '22', '24', '25']
182+
runs-on: ubuntu-latest
183+
timeout-minutes: 120
184+
steps:
185+
- name: Checkout Repository
186+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
187+
with:
188+
persist-credentials: false
189+
submodules: recursive
190+
191+
# Setup node, install deps, and build undici prior to building icu-less node and testing
192+
- name: Setup Node.js@${{ matrix.node-version }}
193+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
194+
with:
195+
node-version: ${{ matrix.node-version }}
196+
197+
- name: Install dependencies
198+
run: npm install
199+
200+
- name: Build undici
201+
run: npm run build:node
202+
203+
- name: Determine latest release
204+
id: release
205+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
206+
with:
207+
result-encoding: string
208+
script: |
209+
const req = await fetch('https://nodejs.org/download/release/index.json')
210+
const releases = await req.json()
211+
212+
const latest = releases.find((r) => r.version.startsWith('v${{ matrix.node-version }}'))
213+
return latest.version
214+
215+
- name: Download and extract source
216+
run: curl https://nodejs.org/download/release/${{ steps.release.outputs.result }}/node-${{ steps.release.outputs.result }}.tar.xz | tar xfJ -
217+
218+
- name: Install ninja
219+
run: sudo apt-get install ninja-build
220+
221+
- name: ccache
222+
uses: hendrikmuhs/ccache-action@bfa03e1de4d7f7c3e80ad9109feedd05c4f5a716 #v1.2.19
223+
with:
224+
key: node${{ matrix.node-version }}
225+
226+
- name: Build node
227+
working-directory: ./node-${{ steps.release.outputs.result }}
228+
run: |
229+
export CC="ccache gcc"
230+
export CXX="ccache g++"
231+
./configure --without-ssl --ninja --prefix=./final
232+
make
233+
make install
234+
echo "$(pwd)/final/bin" >> $GITHUB_PATH
235+
236+
- name: Print version information
237+
run: |
238+
echo OS: $(node -p "os.version()")
239+
echo Node.js: $(node --version)
240+
echo "Node.js built-in dependencies: $(node -p "'\r\n' + (Object.entries(process.versions).map(([k, v], i, arr) => (i !== arr.length - 1 ? '├──' : '└──') + k + '@' + v)).join('\r\n')")"
241+
echo npm: $(npm --version)
242+
echo git: $(git --version)
243+
echo icu config: $(node -e "console.log(process.config)" | grep icu)
244+
245+
- name: Try loading Node.js without Crypto
246+
run: node index.js
247+
175248
test-fuzzing:
176249
name: Fuzzing
177250
runs-on: ubuntu-latest

lib/util/runtime-features.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function detectRuntimeFeatureByNodeModule (moduleName) {
2020
lazyLoaders[moduleName]()
2121
return true
2222
} catch (err) {
23-
if (err.code !== 'ERR_UNKNOWN_BUILTIN_MODULE') {
23+
if (err.code !== 'ERR_UNKNOWN_BUILTIN_MODULE' && err.code !== 'ERR_NO_CRYPTO') {
2424
throw err
2525
}
2626
return false

0 commit comments

Comments
 (0)