Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneesstack72

Relationships

#3738 Source glob expansion crashes when a directory under the glob parent disappears mid-walk

Opened by stack72 · 10/21/2026· Shipped 10/21/2026

What happens

expandSourcePaths (src/infrastructure/persistence/swamp_sources_repository.ts) expands glob sources such as ~/code/* with @std/fs expandGlob. The std walk lists the parent with readDir, then calls Deno.stat on each directory entry it recurses into. If another process removes that directory between the listing and the stat, expandGlob throws NotFound and the whole command fails.

Home directories regularly hold short-lived lock directories (Claude Code's .claude.json.lock is one), so a user whose source glob sits directly under ~ can hit this at random.

Where it is reachable

expandSourcePaths is called from src/cli/repo_context.ts, src/cli/mod.ts, src/libswamp/extensions/reconcile_from_disk_service.ts and src/libswamp/sources/add.ts, list.ts and remove.ts, so it runs during repo-context setup as well as in the source commands.

Reproduction

Point a source glob at a directory where a script keeps creating and removing directories (mkdir/rmdir of a few thousand lock dirs in a loop). Found while triaging swamp-club#3694, where the same race made extension_source_add_test fail 10 of 10 runs under that churn.

Expected

An entry that disappears during expansion is skipped (it no longer exists, so it cannot be a source), and expansion keeps going instead of failing the command.

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 6 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

10/21/2026, 9:13:54 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack7210/21/2026, 6:28:51 PM

Sign in to post a ripple.