Generated backend's own 'test' script fails on Bun 1.4.4: vitest 5.1.1 'child.channel?.unref is not a function', 0 tests run

Aperta
#112 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
61/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
cli, testing

Direzione di ricerca

Start by locating the generated backend package.json and the scaffold tests that generate a Bun backend. Reproduce with Bun 1.4.4 using the reported scaffold commands, then check which generated test script fails under Vitest. Done means a fresh scaffold's bun run test exits successfully with one passing test, with the behavior covered by a scaffold test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: cli area: tests bug dogfood dx first-run has-repro help wanted needs-test priority:medium tech: bun tech: typescript tech: vitest triaged

Summary

The test that flisk resource <name> --type backend writes passes under Bun's runner but the project's own test script (vitest run) fails before any test starts when run through Bun.

Repro (flisk 1.4.73, Bun 1.4.4, macOS)

mkdir demo && cd demo && flisk project --yes
flisk resource api --type backend --framework hono --path api --local --stack app --yes
cd api && bun install
bun test           # 1 pass, 0 fail, 2 expect() calls  (Bun's own runner)
bun run test       # runs "vitest run"

Output of bun run test:

Error: [vitest-pool]: Failed to start forks worker for test files .../tests/api.test.ts.
Caused by: TypeError: child.channel?.unref is not a function.
 Test Files  no tests
      Tests  no tests
     Errors  1 error
error: script "test" exited with code 1

Same with bunx vitest run.

Numbers

Runner Tests found Tests run Result
bun test 1 1 pass
bun run test (vitest run, pinned vitest 5.1.1) 1 0 exit 1
Scripts in generated package.json that need vitest 2 (test, test:watch) of 8
Time to failure about 5 ms

Before

The first command a new user runs after scaffolding a Bun backend (test) fails with an error inside a dependency, and the project looks broken. flisk doctor does not run or mention the test script.

After

  • Generated Bun backends use "test": "bun test" (and "test:watch": "bun test --watch"), or the vitest pool is pinned to threads for Bun, or the vitest pin is bumped to a version that works on Bun.
  • Add a scaffold test: generate a Bun backend and run its test script in CI with the same Bun version as the docs.

Acceptance

In a fresh scaffold, bun run test exits 0 with 1 passed.

Note: Bun on this machine also provides node as a shim (node --version prints "Missing script to execute"), which may be why vitest's forks pool breaks; the fix should not depend on a real Node.

Found by the /dogfood loop. Related: #108.

Lingua principale
TypeScript
Stelle
1
Fork
2
Merge medio
11h 39m
PR unite (30g)
92

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flisk-sh/flisk-cli

Tutte le issue di flisk-sh/flisk-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.