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

#274 Extension bundle cache does not invalidate on source edits

Opened by bixu · 5/7/2026· Shipped 5/7/2026

Problem

When a local extension source is registered with swamp extension source add <path>, swamp builds a .js bundle at <repo>/.swamp/bundles/<hash>/<model>/<model>.js. Subsequent edits to the source .ts files do not invalidate this bundle — swamp model type describe and swamp model method run keep loading the stale .js even though the source has changed.

There is no documented way to force a rebuild:

  • swamp extension source rm <path> followed by swamp extension source add <path> does not rebuild the bundle.
  • The cache-key hash (e.g. e9c5c01e) is stable across source edits.
  • The only working invalidator I found is manually rm'ing the bundle .js. The next type-describe / method-run then rebuilds correctly from source.

Reproduction

  1. swamp extension source add /path/to/dev/checkout
  2. swamp model type describe @hivemq/mymodel --json — bundle gets built at .swamp/bundles/<hash>/mymodel/mymodel.js
  3. Edit extensions/models/mymodel/mymodel.ts to add a new method foo
  4. swamp model type describe @hivemq/mymodel --json again — methods does not include foo
  5. swamp model method run my-instance foo → "method not found"
  6. Workaround: rm <repo>/.swamp/bundles/<hash>/mymodel/mymodel.js and retry — now foo is registered

Impact

This bites hard during local development of pull-based extensions where the user's swamp repo (e.g. ~/.mudroom) has a dev checkout registered as a source and is expected to pick up edits. The failure is silent: wrapper scripts hit "method not found" and exit non-zero, often with the error swallowed by >/dev/null in shell glue.

We hit it twice on @hivemq/mudroom — once on the publisher's checkout, once on the consumer's ~/.mudroom repo. Both times the only repair was manually rming the bundle file.

Proposed solutions (any of these would resolve)

  1. Source mtime check: when loading a bundle, compare its mtime against the max mtime of source .ts files under the registered source path; rebuild if source is newer.
  2. Content-hash key: derive the bundle dir name from a hash of the source tree contents, so any edit naturally produces a fresh bundle and the old one becomes garbage.
  3. Explicit subcommand: swamp extension rebuild <type> or swamp extension cache invalidate <type> for users who want manual control.
  4. Make swamp extension source rm/add invalidate the relevant bundles as a side effect — this matches the existing mental model of "I removed and re-added the source".

Option 1 or 2 would be the most ergonomic. Option 3 is a fine stopgap.

Environment

  • swamp version: 20260506.233640.0-sha.5729ac50
  • Platform: macOS arm64
  • Affected workflows: local extension development, dev/consumer parity testing, mudroom-style "pulled by user, edited by maintainer" loops
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 8 MOREREVIEW+ 3 MOREPR_MERGEDSHIPPED

Shipped

5/7/2026, 6:36:48 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack725/7/2026, 2:58:17 PM

Sign in to post a ripple.