fix(ao): exercise pty.spawn() in postinstall probe, not just require()

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 <noreply@anthropic.com>
This commit is contained in:
Dhruv Sharma 2026-04-09 23:49:33 +05:30
parent e90cc48d6c
commit 628ada0891
1 changed files with 10 additions and 5 deletions

View File

@ -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 {