Skip to content

bug(test): prependEnvVars import fails under concurrent test runs, blocking all local pushes #1223

@namastex888

Description

@namastex888

Symptom

`bun run check` (which runs `bun test` across all 181 test files in parallel) consistently fails with ~10 failures caused by a single cascading module-load error:

```
SyntaxError: Export named 'prependEnvVars' not found in module '.../src/lib/tmux-wrapper.ts'.
at link (unknown:1:11)
at linkAndEvaluateModule (unknown:1:11)
at loadAndEvaluateModule (unknown:2:1)
```

Impact

  • Local pushes via husky pre-push hook are blocked for every contributor
  • The hook runs `bun run check` on every push; the check reports 3106 pass / 11 fail / 7 errors
  • Agents cannot open PRs autonomously because they cannot bypass the hook (`--no-verify` forbidden by agent bible)

Affected test files (all fail to load)

  • `src/lib/tests/transport-aware-liveness.test.ts` (2 tests fail)
  • `src/lib/tests/edge-cases-stability.test.ts`
  • `src/tests/tui-spawn-dx.integration.test.ts`
  • `src/term-commands/agents.test.ts`
  • `src/term-commands/tests/dispatch-slug.test.ts`
  • `src/term-commands/tests/agents-resume.test.ts`
  • `src/term-commands/state.test.ts`
  • `src/term-commands/dispatch.test.ts`

Also-reported (unrelated)

  • `(fail) 7.3 Security > slug validation covers all path traversal vectors` — separate issue
  • `(fail) pen-test: listen-bomb — NOTIFY flood back-pressure response` — separate flaky

Investigation

  • `prependEnvVars` is correctly exported from `src/lib/tmux-wrapper.ts:71`
  • Running `bun test src/lib/tests/transport-aware-liveness.test.ts` in isolation: 10 pass, 0 fail
  • Running `bun test` with all files: same test fails with module-load error
  • The `1 | })` / `2 | {` marker in the trace suggests the file content is being corrupted during concurrent module load — likely a Bun runtime bug or a circular-import/module-cache race

Proposed mitigation

Possible short-term fixes:

  1. Add an explicit import barrel so modules load serially at the start of each test file.
  2. Mark the affected tests `bun.serial` (or isolate them into their own `bun test` invocation in the pre-push script).
  3. File a Bun issue with a minimal reproducer and ship a workaround pending the upstream fix.

Blocker

This gate blocks every non-trivial PR. Because `bun run check` is the pre-push gate, the flake has the same severity as a permanently-red CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions