From 7f576931a9164c979eefa67822c2c16f7ef8a003 Mon Sep 17 00:00:00 2001 From: bntvllnt <32437578+bntvllnt@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:07:52 +0200 Subject: [PATCH] fix(npm): install musl binaries on Linux and surface binary crashes The npm postinstall resolved Linux targets via @napi-rs/triples ordering, which selects the gnu triple. This shipped a binary that can crash (SIGSEGV during the TLS handshake) on some Linux hosts, 404'd on aarch64/arm Linux where only musl assets are published, and diverged from install.sh, which already ships musl to all Linux users to avoid linking issues. The bin wrapper also collapsed every failure into a silent exit 1, discarding both crash signals and the binary's real exit code, which made that crash unreportable (#998). - npm-install/postinstall.js: resolve Linux targets through an explicit musl target map matching the published release assets; other platforms keep the existing triples lookup. - bin/railway.js: print an actionable message when the binary is killed by a signal, and propagate the binary's real exit code. Fixes #998 --- bin/railway.js | 7 ++++++- npm-install/postinstall.js | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/railway.js b/bin/railway.js index f98ab7949..04165a813 100644 --- a/bin/railway.js +++ b/bin/railway.js @@ -12,5 +12,10 @@ try { stdio: "inherit", }); } catch (e) { - exit(1); + if (e.signal) { + console.error( + `The railway binary crashed with ${e.signal}. Please report this at https://github.com/railwayapp/cli/issues`, + ); + } + exit(typeof e.status === "number" ? e.status : 1); } diff --git a/npm-install/postinstall.js b/npm-install/postinstall.js index 2e6389a2e..9ad4b12dc 100644 --- a/npm-install/postinstall.js +++ b/npm-install/postinstall.js @@ -19,9 +19,20 @@ async function install() { // Fetch Static Config let { name: binName, path: binPath, url } = CONFIG; - let triple = triples.platformArchTriples[process.platform][process.arch][0]; - - url = url.replace(/{{triple}}/g, triple.raw); + // Linux: statically linked musl builds, same policy as install.sh (the gnu + // build crashes on some hosts, see #998; arm/arm64 only publish musl). + const linuxTargets = { + x64: "x86_64-unknown-linux-musl", + arm64: "aarch64-unknown-linux-musl", + ia32: "i686-unknown-linux-musl", + arm: "arm-unknown-linux-musleabihf", + }; + const triple = + process.platform === "linux" + ? linuxTargets[process.arch] + : triples.platformArchTriples[process.platform][process.arch][0].raw; + + url = url.replace(/{{triple}}/g, triple); url = url.replace(/{{version}}/g, version); url = url.replace(/{{bin_name}}/g, binName); console.log(url);