Bundle cache fallback silently skipped when source and bundle have equal mtimes
Opened by 4chems · 4/9/2026· Shipped 4/9/2026
Description
The bundler has a fallback: if rebundling fails, use the cached bundle. That fallback is only reached when the cached file is strictly newer than all source files (bundleStat.mtime > newestSourceMtime). When both are written in the same second (e.g. source file and bundle created in the same pre-commit hook run), the check fails (> not >=), and the code falls through to attempt a rebundle — which then fails because imports are missing.
The result: every swamp invocation attempts and fails to rebundle, adds the types to result.failed, and never populates the catalog. The cached bundles exist but are never used.
Steps to Reproduce
- Have a local extension with valid cached
.jsbundles in.swamp/bundles/ - Ensure the source file and bundle file have the same mtime (e.g. written in the same second)
- Run any
swampcommand that loads models - Observe:
Failed to load user modelerrors, despite valid cached bundles existing on disk
Expected Behavior
The cached bundle should be used when bundleStat.mtime >= newestSourceMtime (i.e. >= not >), or the cache should be used unconditionally when required dependencies are missing.
Environment
- swamp version: 20260409.030033.0-sha.07dae003
- OS: macOS Darwin 25.3.0
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.