DEV Community

relkimm
relkimm

Posted on

Turbopack keeps crashing? I made a CLI that auto-restarts it.

I've been using Claude Code for my side projects lately.

It's great, but there's one problem. Claude keeps editing files automatically, which triggers rebuilds. And Turbopack doesn't handle that well.

The loop became my life:

  1. Claude edits a file
  2. Turbopack crashes
  3. Ctrl+C → npm run dev
  4. Claude edits another file
  5. Crash again
  6. Ctrl+C → npm run dev
  7. ...repeat all day

After a weekend of this, I built a CLI to handle it automatically.


next-zombie 🧟

npx next-zombie
Enter fullscreen mode Exit fullscreen mode

It watches your dev server. When it crashes, it restarts. Automatically.

No more Ctrl+C. No more switching terminals. Just keep coding.

It also clears .next cache before each restart.


What It Looks Like

Starting up:

$ npx next-zombie
[next-zombie] Cleaning .next cache...
[next-zombie] Starting Next.js with auto-recovery...
[next-zombie] $ pnpm run dev

  ▲ Next.js 15.0.3 (Turbopack)
  - Local:        http://localhost:3000

 ✓ Ready in 1.2s
Enter fullscreen mode Exit fullscreen mode

When crash happens:

 ⨯ [Error: ENOENT: no such file or directory, open '.next/static/development/_buildManifest.js.tmp']

[next-zombie] Cache error detected!
[next-zombie] Restarting in 0.5s...
[next-zombie] Cleaning .next cache...
[next-zombie] Restarting... (#1)
[next-zombie] Starting Next.js with auto-recovery...
[next-zombie] $ pnpm run dev

  ▲ Next.js 15.0.3 (Turbopack)
  - Local:        http://localhost:3000

 ✓ Ready in 1.1s
Enter fullscreen mode Exit fullscreen mode

On exit:

^C
[next-zombie] Session: 3 restarts, uptime 1h 42m
Enter fullscreen mode Exit fullscreen mode

Before & After

Before:

Crash → Ctrl+C → npm run dev → Crash → Ctrl+C → npm run dev → ...
Enter fullscreen mode Exit fullscreen mode

After:

Crash → [next-zombie restarts] → keep coding
Enter fullscreen mode Exit fullscreen mode

Recovery time: ~700ms


How It Works

next-zombie
    │
    ├─► Start: pnpm run dev
    │
    ├─► Monitor stdout/stderr
    │       │
    │       ├─► Cache error? → Restart
    │       │
    │       └─► Crash? → Restart
    │
    └─► Ctrl+C → Show stats → Exit
Enter fullscreen mode Exit fullscreen mode

Detected patterns:

  • _buildManifest.js.tmp ENOENT
  • .next cache errors
  • Any non-zero exit

Features

  • Auto-restart — no more Ctrl+C loop
  • Auto cache clearing — clears .next before restart
  • PM detection — works with npm, pnpm, yarn, bun
  • Session stats — see how many restarts happened

Install

Try it now:

npx next-zombie
Enter fullscreen mode Exit fullscreen mode

Add to project:

npm install -D next-zombie
Enter fullscreen mode Exit fullscreen mode
{
  "scripts": {
    "dev": "next-zombie"
  }
}
Enter fullscreen mode Exit fullscreen mode

FAQ

Q: Does this fix Turbopack?

No. It's a workaround. When Turbopack crashes, next-zombie handles the restart.

Q: Production?

Dev only. Production builds don't have this issue.

Q: Why not disable Turbopack?

You can. But Turbopack is fast. I'd rather have speed + auto-recovery.


Links


If this saves you some frustration:

Star on GitHub

Found a new crash pattern?

🐛 Open an issue


Let the zombie handle the restarts. 🧟

Top comments (0)