From 628ada08912e93ceed4f78dbc0fd4c94227ddd27 Mon Sep 17 00:00:00 2001 From: Dhruv Sharma Date: Thu, 9 Apr 2026 23:49:33 +0530 Subject: [PATCH] fix(ao): exercise pty.spawn() in postinstall probe, not just require() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The require('node-pty') check only verifies the module loads, but the actual posix_spawnp failure only surfaces when the helper binary is executed via pty.spawn(). This means the probe could pass while the terminal remains broken — exactly the scenario issue #987 describes. Co-Authored-By: Claude Opus 4.6 --- packages/ao/bin/postinstall.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/ao/bin/postinstall.js b/packages/ao/bin/postinstall.js index cbdc28c0a..46bc804a5 100644 --- a/packages/ao/bin/postinstall.js +++ b/packages/ao/bin/postinstall.js @@ -56,12 +56,17 @@ if (existsSync(spawnHelper)) { // Step 2: Verify the prebuilt binary actually works with this Node.js version. // If it doesn't (ABI mismatch from nvm/fnm/volta version switching), rebuild. +// We exercise pty.spawn() — not just require() — because the posix_spawnp +// failure only surfaces when the helper binary is actually executed. try { - execSync("node -e \"require('node-pty')\"", { - cwd: resolve(nodePtyDir, ".."), - stdio: "ignore", - timeout: 10000, - }); + execSync( + "node -e \"var p=require('node-pty');var t=p.spawn('/bin/sh',['-c','exit 0'],{});t.kill();\"", + { + cwd: resolve(nodePtyDir, ".."), + stdio: "ignore", + timeout: 10000, + }, + ); } catch { console.log("\u26a0\ufe0f node-pty prebuilt binary incompatible with Node.js " + process.version + ", rebuilding..."); try {