From d2a33cc005a4c26768b745d0b2ecb887d3a6b452 Mon Sep 17 00:00:00 2001 From: leeguooooo Date: Sat, 9 May 2026 12:58:39 +0900 Subject: [PATCH] fix(scripts): serialize all-platforms build + per-pid wait checks Two related bugs that conspired to ship stale linux binaries on 0.27.0-fork.5/.7/.8 (caught only by manually grepping the embedded version string each release): 1. build:all-platforms used `(... & npm run build:linux & wait)`. The bare `wait` waits for ALL children but exits with the LAST waited child's status, not each individually. So if linux fell over and windows succeeded last, the script reported success. Worse, when both processes shared cli/target/ and fought over cargo's filesystem locks, one would silently bail out and the missing binary just stayed at the previous release's bytes. Now serial: `npm run build:linux && npm run build:windows && npm run build:macos`. Costs ~3 extra minutes wall-clock vs. parallel; trades latency for "every release ships what it says". 2. build:macos had the same `(... & ... & wait)` parallel pattern for arm64 + x64 cross-compiles. Native cargo builds against the same target/ dir share even more state than the docker'd Linux build did, so the failure mode is the same. Now uses explicit `PID1=$!; PID2=$!; wait $PID1 || exit 1; wait $PID2 || exit 1` so both must succeed. Companion to the docker-compose $$ fix in 947d150 (which fixed the *inside-container* wait+cp eating shell vars). This one fixes the *outer* npm-script layer. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3cfc52a..0dbc843 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "version": "npm run version:sync && git add cli/Cargo.toml", "build:native": "npm run version:sync && cargo build --release --manifest-path cli/Cargo.toml && node scripts/copy-native.js", "build:linux": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-linux", - "build:macos": "npm run version:sync && (cargo build --release --manifest-path cli/Cargo.toml --target aarch64-apple-darwin & cargo build --release --manifest-path cli/Cargo.toml --target x86_64-apple-darwin & wait) && cp cli/target/aarch64-apple-darwin/release/agent-browser bin/agent-browser-darwin-arm64 && cp cli/target/x86_64-apple-darwin/release/agent-browser bin/agent-browser-darwin-x64", + "build:macos": "npm run version:sync && bash -c 'cargo build --release --manifest-path cli/Cargo.toml --target aarch64-apple-darwin & PID1=$!; cargo build --release --manifest-path cli/Cargo.toml --target x86_64-apple-darwin & PID2=$!; wait $PID1 || exit 1; wait $PID2 || exit 1' && cp cli/target/aarch64-apple-darwin/release/agent-browser bin/agent-browser-darwin-arm64 && cp cli/target/x86_64-apple-darwin/release/agent-browser bin/agent-browser-darwin-x64", "build:windows": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-windows", - "build:all-platforms": "npm run version:sync && (npm run build:linux & npm run build:windows & wait) && npm run build:macos", + "build:all-platforms": "npm run version:sync && npm run build:linux && npm run build:windows && npm run build:macos", "build:docker": "docker build -t agent-browser-builder -f docker/Dockerfile.build .", "release": "npm run version:sync && npm run build:all-platforms && npm publish --tag fork", "postinstall": "node scripts/postinstall.js"