Repository navigation
Description
Summary
Refreshing a git: marketplace — manually, on bb marketplace add, and on every periodic refresh — runs a full git clone of the marketplace repository, checks out the whole tree, and then deletes .git. It does this even when the ref still points at the commit bb already has stored. For a marketplace monorepo with a long history, every refresh takes well over a minute to produce a catalog that bb could have read in under a second. I expected a refresh to check whether the ref moved and, when it did, to fetch only the catalog and its icons.
#7910 / #7911 fixed the same clone for plugin installs; the marketplace refresh path in marketplace-source.ts was not touched.
Versions and environment
- bb built from
mainatd73dac8c906f34b7e722f8446b10958ad8e278dd, macOS 27.2.1, git 2.56.1 - Reproduced through
createPluginCatalogServiceagainst a real git marketplace; no provider involved
Steps to reproduce
- Register a marketplace whose source is a git monorepo with a long history, e.g.
bb marketplace add git:github.com/<org>/<marketplace-monorepo>@main. time bb marketplace refresh <name>without pushing anything to the repository.- While it runs,
ps aux | grep 'git -c core.hooksPath=/dev/null clone'anddu -sh <dataDir>/marketplaces/staging/*/.git.
Fixture-level repro: after addMarketplace of a local git fixture, delete the repository's loose objects so that git ls-remote still answers but any clone or fetch fails. refreshMarketplaces fails on main even though nothing changed; with the fix it succeeds from the stored catalog.
Expected vs actual
Measured through createPluginCatalogService against the marketplace monorepo that prompted this (89 entries, 39 icons, 2,967 commits, 826 MiB pack), same machine and network:
| Step | main |
with ls-remote + blobless sparse fetch |
|---|---|---|
addMarketplace (ref moved) |
87.05 s | 3.54 s |
refreshMarketplaces (ref unchanged) |
87.72 s | 0.75 s |
Raw git timings against the same repository:
git ls-remote <url> main 0.96 s
git clone --quiet --no-checkout <url> (what refresh does) 1m24.5 s 826 MiB pack, 85,650 objects
git checkout --detach origin/main 0.9 s 157 MB working tree
git clone --depth 1 --no-checkout <url> 8.4 s 81 MB
git clone --filter=blob:none --no-checkout <url> 1.7 s 7.5 MB
What the refresh actually reads from that checkout is marketplace.json (346 KB) and icons/ (152 KB): fetchMarketplaceIcons reads local icons from disk, screenshots are only resolved to URLs, and .git is deleted right after checkout. The other 112 MB of plugins/, 31 MB of screenshots/, 12 MB of media/ and ~800 MB of history (including deleted multi-MB video and dataset blobs) are downloaded and thrown away.
Expected: a refresh costs one ls-remote when the ref has not moved, and a fetch proportional to the catalog when it has.
Evidence
materializeGitonmain:—bb/apps/server/src/services/plugin-catalog/marketplace-source.ts
Lines 377 to 431 in d73dac8
async function materializeGit( source: Extract<MarketplaceSource, { kind: "git" }>, stagingDir: string, warn: ((message: string) => void) | undefined, ): Promise<MaterializedMarketplace> { await mkdir(stagingDir, { recursive: true }); const checkout = join(stagingDir, randomUUID()); const dispose = () => rm(checkout, { recursive: true, force: true }); try { await runInstallCommand("git", [ ...GIT_CLONE_ARGS, "clone", "--quiet", "--no-checkout", source.url, checkout, ]); const commit = await runInstallCommand("git", [ "-C", checkout, "rev-parse", "--verify", "--end-of-options", `${source.ref}^{commit}`, ]).catch(() => runInstallCommand("git", [ "-C", checkout, "rev-parse", "--verify", "--end-of-options", `refs/remotes/origin/${source.ref}^{commit}`, ]), ); await runInstallCommand("git", [ ...GIT_CLONE_ARGS, "-C", checkout, "checkout", "--quiet", "--detach", commit, ]); await rm(join(checkout, ".git"), { recursive: true, force: true }); return await materializeLocal( await gitMarketplaceRoot(checkout, source.subdirectory), commit, dispose, warn, ); } catch (error) { await dispose(); throw error; } } clone --no-checkoutwith no--depth/--filter,rev-parse <ref>,checkout --detach,rm .git. The storedsourceGitCommitis never consulted.- Both the refresh and the add path call it after wiping the staging dir: and
if (source.kind === "git") await prepareMarketplaceStaging(); .if (source.kind === "git") await prepareMarketplaceStaging(); refreshMarketplacesrefreshes marketplaces sequentially, so one slow git marketplace delays every other one:.bb/apps/server/src/services/plugin-catalog/plugin-catalog-service.ts
Lines 755 to 768 in d73dac8
async function refreshMarketplaces(args?: { name?: string; attemptedAt?: number; }): Promise<PluginMarketplaceRefreshResult[]> { const attemptedAt = args?.attemptedAt ?? Date.now(); if (args?.name !== undefined) { requireEnabledRow(args.name); return [await refreshOne(args.name, attemptedAt)]; } const results: PluginMarketplaceRefreshResult[] = []; for (const row of enabledMarketplaces()) { results.push(await refreshOne(row.name, attemptedAt)); } return results; resolveGitRefinupdate-resolver.tsalready resolves a branch, tag or SHA to a commit with onels-remote, and is what plugin installs use.- Timings measured with
performance.now()around the service calls andtimearound the raw git commands.
What you ruled out
- Not the icon step or the database write: icons are 152 KB of local reads and the upsert is one transaction; after the clone everything else is sub-second.
- Not the https path:
materializeHttpsalready short-circuits on ETag /If-Modified-Sinceand usesonlyMissingfor icons; onlygit:sources redo all the work. - Not a duplicate of Plugin git installs clone the whole repository instead of fetching the resolved commit #7910 (plugin installs, fixed in Fetch only the resolved commit for git plugin installs #7911) or Plugin git installs check out the whole repository tree when only one subdirectory is selected #8115 (plugin install checkout, Check out only the selected plugin's directories for git installs #8116): both are in
managed-plugin-artifacts.ts; the marketplace refresh has its own clone inmarketplace-source.ts. Searched "marketplace refresh", "marketplace clone", "marketplace slow" in open and closed issues;bb marketplace addfails for a git branch other than the default branch #5373 and Read a git marketplace'smarketplace.jsonfrom a subdirectory #5372 are about which ref/subdirectory is read, not how much is fetched.
Suggested priority and effort
Hits every user of a git marketplace on every periodic refresh, and makes bb marketplace add / first-run setup of such a marketplace take minutes; no workaround short of mirroring the catalog to an https URL. Contained change in materializeGit: resolveGitRef first and reuse the stored catalog when the commit matches; otherwise init + fetch --depth 1 --filter=blob:none <sha> + cone-mode sparse-checkout of the root (plus the icon directories the manifest names) or of the selected subdirectory, falling back to the existing full clone when the ref cannot be resolved by ls-remote or the server refuses the fetch. Fix with tests in the linked PR.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 24, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotplugins,perf.confirmed-repro.mainin two clean checkouts: refresh keeps the same commit but performs another clone. All 40 existing marketplace tests pass. A separate probe confirms unrelated files are checked out and Git metadata is discarded.Skip unchanged git marketplaces and fetch only the catalog on refresh (…