Skip to content

test(bundles): make remote-lifecycle name-ref test hermetic#366

Merged
mgoldsborough merged 1 commit into
mainfrom
fix/flaky-remote-lifecycle-hermetic
Jun 3, 2026
Merged

test(bundles): make remote-lifecycle name-ref test hermetic#366
mgoldsborough merged 1 commit into
mainfrom
fix/flaky-remote-lifecycle-hermetic

Conversation

@mgoldsborough
Copy link
Copy Markdown
Contributor

Summary

The startBundleSource — remote url entries > handles mix of name, path, and url entries via allSettled integration test flakes intermittently in CI with a 15s timeout (seen most recently on #300's CI).

Root cause

The test passes an unresolvable { name: "@nonexistent/bundle" } ref through startBundleSource and asserts it rejects. An uncached name cache-misses, so the mpak SDK falls through to a public-registry fetch (https://registry.mpak.dev/v1/bundles/...). When that fetch 404s quickly the test passes; under a slow CI network the round-trip exceeds the test's 15s budget and the test times out. It's a non-hermetic test reaching the public internet.

Fix

Isolate MPAK_HOME to a temp dir whose config.json points registryUrl at a closed local port (http://127.0.0.1:1). The name lookup now returns ECONNREFUSED immediately instead of hanging — the ref still rejects (preserving the test's intent: a mix of failing name/path refs alongside a succeeding url ref), but fast and offline.

Scoped to the one describe block that uses a name ref; MPAK_HOME is saved and restored in beforeEach/afterEach so sibling tests and other files are unaffected.

Verification

  • Previously-flaky test: 170ms (was a 15s timeout)
  • bun run test:integration: 654 pass / 12 skip / 0 fail
  • bun run lint / format:check / check: clean

This is a test-only change — no production code touched.

The 'handles mix of name, path, and url entries' test passed an
unresolvable { name } ref through startBundleSource and asserted it
rejects. An uncached name cache-misses and the mpak SDK fetches the
public registry (https://registry.mpak.dev); under a slow CI network
that round-trip blew the test's 15s budget and flaked intermittently.

Isolate MPAK_HOME to a temp dir whose config.json points the registry
at a closed local port, so the lookup returns ECONNREFUSED immediately
instead of hanging. The test now rejects fast and offline (170ms vs a
15s timeout) with no public-network dependency.
@mgoldsborough mgoldsborough merged commit 805977f into main Jun 3, 2026
5 checks passed
@mgoldsborough mgoldsborough deleted the fix/flaky-remote-lifecycle-hermetic branch June 3, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant