Relationships
#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
- 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> - Delete the bundle file:
rm .swamp/bundles/<hash>/<name>.js - 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-walThe 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.
Related
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-realmextension version.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.