Fail fast when bootstrapping workspaces#378
Closed
kraenhansen wants to merge 1 commit into
Closed
Conversation
The root `bootstrap` script ran `npm run bootstrap --workspaces --if-present`, but npm does not fail fast across workspaces: when one workspace's bootstrap fails, npm keeps running the bootstrap script for the remaining workspaces and only reports a non-zero exit code at the end. Because later workspaces depend on artifacts produced by earlier ones (e.g. the weak-node-api xcframework consumed by node-addon-examples, node-tests and ferric-example), a failure while building weak-node-api produced a cascade of confusing secondary "missing xcframework" errors that buried the actual root cause. Replace the `--workspaces` iteration with a small script that bootstraps each workspace in declared order and stops at the first failing one, so CI surfaces the real error instead of the downstream cascade. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MFfJiaaqbgMqnrNUB6e76m
Collaborator
Author
|
I think this gives me the collateral to resurrect #204 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
npm run bootstrapstep in CI (e.g. this Test app (iOS) run) doesn't stop on the first real error. Instead it continues and fails a series of secondary commands that only fail because an earlier command failed, making the log noisy and the real root cause hard to spot.Root cause
The root
bootstrapscript was:npm's
--workspacesiteration is not fail-fast. When one workspace'sbootstrapscript exits non-zero, npm keeps running thebootstrapscript for every remaining workspace and only surfaces a non-zero exit code once they've all run.In the linked run, the actual first failure is
weak-node-api's bootstrap — a CMake configuration error prevents theweak-node-api.xcframeworkfrom being produced:That exit code is propagated correctly, but because npm doesn't fail fast, the workspaces that consume the xcframework then run and fail with confusing downstream errors:
node-addon-examples→Expected an XCFramework at .../weak-node-api/build/Release/weak-node-api.xcframeworknode-tests→ same missing-xcframework assertionferric-example→No matching slice found in weak-node-api.xcframework for target aarch64-apple-ios-simSo the run "doesn't fail on the first error" — it fails three more times on commands that depend on the first one having succeeded, and the genuine root cause (the CMake error in
weak-node-api) is buried in the middle of the log.Fix
Replace the non-fail-fast
--workspacesiteration with a smallscripts/bootstrap.tsthat:weak-node-apibefore its consumers),npm run bootstrap --workspace <name>for each workspace that has abootstrapscript (preserving the--if-presentsemantics),This mirrors the existing
scripts/run-in-published.tspattern already used in the repo.Verification
Reproduced npm's non-fail-fast behavior with a 3-workspace fixture (
aok,bfails,cok):cstill ran afterbfailed, matching the CI log. Ran the newscripts/bootstrap.tsagainst the same fixture:bfails →cis not run, script exits1immediately.bootstrapscript runs, workspaces without one are skipped, script exits0.Also confirmed the generated bootstrap plan against the real repo matches the previous behavior exactly (
weak-node-api→host→node-addon-examples→node-tests→ferric-example, with script-less workspaces skipped).Follow-up (not in this PR)
The
prereleaseroot script uses the same non-fail-fast pattern (npm run prerelease --workspaces --if-present) and would benefit from the same treatment.🤖 Generated with Claude Code
https://claude.ai/code/session_01MFfJiaaqbgMqnrNUB6e76m
Generated by Claude Code