Skip to main content
← Back to list
01Issue
BugShippedSwamp CLI
Assigneeskeeb

#212 swamp model type describe fails with 'No such file' instead of rebundling when bundle is missing

Opened by 4chems · 5/2/2026· Shipped 5/2/2026

Summary

When a user-defined extension's bundle file under .swamp/bundles/<hash>/<name>.js is missing — but the extension catalog (.swamp/_extension_catalog.db) still references it by absolute path — swamp model type describe, swamp model method run, and other type-resolving operations fail with:

No such file or directory (os error 2): readfile '/.../.swamp/bundles/<hash>/<name>.js'

The error originates in UserModelLoader.importBundleByPath (per the trace). swamp does not fall back to a rebundle from source even though the source .ts file is present.

Reproducer

  1. In a swamp repo with a user extension under extensions/models/<name>.ts, run any command that loads the type so the catalog and bundle exist:
    swamp model type describe @user/<name>
  2. Delete the bundle file:
    rm .swamp/bundles/<hash>/<name>.js
  3. Re-run the same command. Expected: swamp detects the missing bundle and rebuilds it from source. Actual: throws No such file or directory (os error 2).

Workaround

Force a full catalog rescan (which also re-bundles):

rm .swamp/_extension_catalog.db .swamp/_extension_catalog.db-shm .swamp/_extension_catalog.db-wal

The next swamp invocation rebuilds the catalog and bundles. (Alternative: rm -rf .swamp/bundles plus the catalog removal — both needed for a clean rebuild.)

Triggers in normal use

  • Extension version bump that should rebundle but doesn't (the freshness check or upgrade path doesn't always recreate the bundle).
  • Cleaning .swamp/bundles/ partially during local debugging.
  • A failed previous bundle attempt leaving the catalog with a stale path entry.

Distinct from but in the same area as docs/learning/swamp-bundle-cache-timestamp.md: the prior > vs >= mtime fallback issue (rebundle attempt fails because deps missing → falls back to cache only when bundleStat.mtime > newestSourceMtime). Today's failure mode is the inverse — the bundle is missing, not stale-mtime — and the loader errors out instead of attempting a rebundle.

Suggested fix

In UserModelLoader.importBundleByPath, when the bundle file is absent, fall through to a rebundle-from-source path (the same code path used on first load) instead of bubbling up the file-not-found error. Alternatively, on every catalog hit, check that the referenced bundle file exists; if not, treat the catalog entry as stale and re-resolve from source.

Environment

  • swamp 20260424.000956.0-sha.25668e08
  • macOS Darwin 25.4.0 (Apple Silicon, sandbox not relevant)
  • Reproduced 2026-05-02 in a real ops repo while bumping a @4chems/keycloak-realm extension version.
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 3 MOREPR_MERGEDSHIPPED

Shipped

5/2/2026, 5:16:41 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
keeb assigned keeb5/2/2026, 2:43:03 PM

Sign in to post a ripple.