Repository navigation
Conversation
Community plugins whose prebuilt dist targets another SDK version fall back to a source build, and the cache for those builds was keyed by a hash of the finished bundle, so every bb launch ran the full esbuild build before it could find the cached copy. Each build now records the state of everything that decided its output, and the next load checks that record before building: - every bundled file, by content; - every package.json, tsconfig.json and jsconfig.json from each bundled file's directory up to the filesystem root (absent ones included, so creating one invalidates), plus the files those tsconfigs extend; - the directory listing of each bundled file's directory and its ancestors inside the plugin root, so a new file that changes resolution (foo.ts beside foo.js, a new node_modules package) invalidates. The record is written only when no tracked path's mtime or ctime is at or after the build started (read from the stage directory's timestamp, with slack for whole-second filesystems). A file saved mid-build therefore never gets cached as current. Because every recorded stat predates the build, a later load can trust a matching size, mtime, ctime and inode without reading the file. It hashes only paths whose stat changed, with 64 checks in flight at once. For a plugin bundling 945 node_modules files, a cache hit takes ~6-12 ms against a ~500 ms build (serially hashing every input took ~50 ms). buildPluginServer now returns the bundled input paths from esbuild's metafile. Fixes #5729 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cache key named the bb version but not the code that bundles plugins, so a dev checkout that changed @bb/plugin-build kept serving plugin builds made by the old code. The key now includes a digest of the code files beside @bb/plugin-build's module: its source in a source checkout, and the server bundle in built and packaged bb. A failure while recording a finished build's inputs now skips the record instead of failing a load whose build succeeded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/5729-community-plugins-rebuild-on-every-bb-launc-thr_8entu4ue7q
branch
October 28, 2026 19:41
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.
Human comments
What was wrong
Community plugins whose prebuilt server bundle targets another plugin SDK version fall back to a source build, which is intentional while the SDK is pre-1.0. The cache for those source builds was looked up by a hash of the finished bundle (
apps/server/src/services/plugins/plugin-server-cache.ts), so bb ran the full esbuild build on every launch before it could find the cached copy. A cache hit saved nothing (#5729).What changed
The cache is now checked before building, with nothing skipped that could make the reused build stale.
packages/plugin-build/src/build-plugin-server.ts:buildPluginServeralso returns the bundled input files from the esbuild metafile.packages/plugin-build/src/code-digest.ts(new):pluginBuildCodeDigest()hashes the code files next to plugin-build's module. That is plugin-build's source in a source checkout and the server bundle in built and packaged bb, so a dev checkout that changes the build code doesn't serve builds made by the old code. It runs once per process, about 15 ms on the 9.6 MB server bundle.apps/server/src/services/plugins/plugin-server-cache.ts(rewritten, same export and signature): each build stores abuild.jsonthat a later load checks before building.package.json,tsconfig.jsonandjsconfig.jsonin every ancestor directory, with missing ones recorded so that creating one invalidates;extends;foo.tsbesidefoo.jsinvalidates.There are no wire, database, CLI or public SDK changes. This deviates from the issue's proposed fix only in going further: it tracks resolution inputs beyond the plugin source so that a cache hit can't be stale.
How you verified
apps/server/test/services/plugins/plugin-server-cache.test.tsandprebuilt-server-loading.test.ts. I confirmed each fails when its fix is removed:pathschange, an extended tsconfig change, a dependency'sexportschange and a newfoo.tsbesidefoo.jseach rebuild (fail when only bundled files are tracked; the extended-tsconfig case also fails without followingextends).pnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/plugin-buildpasses. The cache and prebuilt-loading tests pass (17), and the@bb/plugin-buildsuite passes.pnpm start:worktreeserver: I installed the community plugin Agent Graph and changed the stamp in itsdist/server.meta.jsonto SDK 0.6.93 to simulate a bb update.server.tsrebuilt it, and reverting the edit reused the original build.apps/server/test/services/plugins, two builtin-plugin watcher tests flaked under heavy load. Main fails one of them in the same run, and both pass when their file runs alone.Fixes #5729
🤖 Generated with Claude Code