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:
parent
e90cc48d6c
commit
628ada0891
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue