diff --git a/packages/host-watcher/src/workspace-status-watcher.ts b/packages/host-watcher/src/workspace-status-watcher.ts index df266c0db..3d5f549b6 100644 --- a/packages/host-watcher/src/workspace-status-watcher.ts +++ b/packages/host-watcher/src/workspace-status-watcher.ts @@ -31,6 +31,15 @@ const WORKSPACE_STATUS_WATCH_MAX_RETRY_DELAY_MS = 30_000; // (resetting the count) when the watch set changes. const WORKSPACE_STATUS_WATCH_MAX_SETUP_RETRY_ATTEMPTS = 10; const WORKSPACE_ROOT_ALWAYS_IGNORED_PATHS = [".git"]; +// Recursive globs: picomatch against the path relative to the watch root and +// FTS_SKIP'd during parcel's initial crawl, so nested checkouts' heavy trees +// never get an inotify watch (get-bb/bb#1779). Independent of git discovery. +const WORKSPACE_ROOT_ALWAYS_IGNORED_GLOBS = [ + "**/.git", + "**/node_modules", + "**/.cache", + "**/__pycache__", +]; const WORKSPACE_ROOT_IGNORE_STATUS_TIMEOUT_MS = 5_000; const WORKSPACE_ROOT_IGNORE_STATUS_MAX_BUFFER_BYTES = 10 * 1024 * 1024; @@ -105,6 +114,7 @@ function mergeWorkspaceRootIgnores(gitIgnoredPaths: string[]): string[] { const ignoredPaths = new Set(); for (const ignoredPath of [ ...WORKSPACE_ROOT_ALWAYS_IGNORED_PATHS, + ...WORKSPACE_ROOT_ALWAYS_IGNORED_GLOBS, ...gitIgnoredPaths, ]) { ignoredPaths.add(ignoredPath); @@ -223,6 +233,14 @@ export class WorkspaceStatusWatcher { // root without excluding `.git` until that marker appears. this.startWatchSubscription({ kind: "workspace-root", + // Keep `/.git` visible so `git init` promotion still fires, but + // skip nested checkouts' `.git` and the heavy trees. + options: { + ignore: [ + "*/**/.git", + ...WORKSPACE_ROOT_ALWAYS_IGNORED_GLOBS.filter((g) => g !== "**/.git"), + ], + }, rootPath, }); return; @@ -271,7 +289,12 @@ export class WorkspaceStatusWatcher { // too slow or its metadata is temporarily unavailable. this.startWatchSubscription({ kind: "workspace-root", - options: { ignore: [...WORKSPACE_ROOT_ALWAYS_IGNORED_PATHS] }, + options: { + ignore: [ + ...WORKSPACE_ROOT_ALWAYS_IGNORED_PATHS, + ...WORKSPACE_ROOT_ALWAYS_IGNORED_GLOBS, + ], + }, rootPath, }); }