Refresh the served bb-app artifact after restart - #877
Merged
SawyerHood merged 2 commits intoJul 28, 2026
Conversation
Review follow-up to the once-per-process rebuild. Deleting the destination tarball before rebuilding turned a transient build failure into a hard outage: the previous artifact was already gone, so `/install/bb-app.tgz` had nothing to serve and remote daemons could neither install nor repair a protocol mismatch. Before this branch a valid cache entry short-circuited ahead of that delete, so the regression only appeared once every restart started rebuilding. Publish by atomic rename instead. `npm pack` writes `bb-app-<version>.tgz` and the destination always appends `-protocol-<n>`, so the two names can never collide; both sit in the cache directory, so the rename is same-filesystem and replaces the old artifact in one step. A failed build now leaves the last good tarball in place. The metadata sidecar is still removed so older installs clean themselves up. Also drop the module-level `pendingBuilds` map. Per-instance memoization of the build promise already collapses concurrent callers, and the server constructs exactly one artifact service per process, so the map only added a second dedupe layer that could never fire. Both new expectations fail against the pre-change file in all three layouts (repo-src, repo-dist, packaged). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
/install/bb-app.tgzonce per server process from the package that process is actually runningWhy
The machine installer promises the exact build served by the current server because unpublished builds can share a version. The persisted cache contradicted that contract: after restarting into a different source build with the same package version and protocol, the server kept serving the previous process's tarball. Remote machines could therefore reinstall successfully and still run stale daemon/bridge code.
Verification
mainin all three supported layouts (repo-src,repo-dist, packaged) and passes with this changepnpm exec turbo run test --filter=@bb/server --force— 1,258 passedpnpm exec turbo run typecheck --filter=@bb/server --force— passedpnpm exec turbo run build --filter=@bb/server --force— passedgit diff --check— passed