Skip to content

EBADF thrown when restarting workerd on vite server restart #11675

@spalger

Description

@spalger

What versions & operating system are you using?

System:
  OS: macOS 26.1
  CPU: (14) arm64 Apple M4 Pro
  Memory: 1.30 GB / 48.00 GB
  Shell: 5.9 - /opt/homebrew/bin/zsh
Binaries:
  Node: 22.12.0 - /Users/spencer.alger/.local/state/fnm_multishells/96545_1765904624516/bin/node
  Yarn: 4.12.0 - /Users/spencer.alger/.local/state/fnm_multishells/96545_1765904624516/bin/yarn
  npm: 10.9.0 - /Users/spencer.alger/.local/state/fnm_multishells/96545_1765904624516/bin/npm
  bun: 1.2.19 - /Users/spencer.alger/Developer/ramp/web/.devbox/nix/profile/default/bin/bun
npmPackages:
  @cloudflare/vite-plugin: 1.13.7 => 1.13.7 
  wrangler: 4.40.2 => 4.55.0 

Please provide a link to a minimal reproduction

I was unable to produce a repro outside of our proprietary repo unfortunately, definitely tried, open to ideas about what I might need to replicate.

Describe the Bug

We're seeing a consistent issue when we change our vite config and the cloudflare plugin tries to restart the workerd process. When this code runs at startup everything is fine, but when we update our vite config and this code runs again it throws an EBADF error that I can't quite wrap my head around.

I'm not 100% sure this is actually a workerd issue, but the error is definitely coming from the workerd library and I'm really hoping that someone might have a brilliant idea that helps explain why this is happening. If nothing else, it was surprising that nobody has filed such an issue yet.

command

"@@/node_modules/@cloudflare/workerd-darwin-arm64/bin/workerd"

args

[
  "serve",
  "--binary",
  "--experimental",
  "--socket-addr=entry=127.0.0.1:0",
  "--external-addr=loopback=127.0.0.1:51001",
  "--control-fd=3",
  "-",
  "--inspector-addr=localhost:9229",
]

and the error thrown:

{
  errno: -9,
  code: "EBADF",
  syscall: "spawn",
  stack: `Error: spawn EBADF
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at Object.spawn (node:child_process:753:9)
    at Runtime.updateConfig (@@/node_modules/miniflare/dist/src/index.js:49746:57)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async #assembleAndUpdateConfig (@@/node_modules/miniflare/dist/src/index.js:61776:30)
    at async #setOptions (@@/node_modules/miniflare/dist/src/index.js:62026:5)
    at async Mutex.runWith (@@/node_modules/miniflare/dist/src/index.js:38857:48)
    at async BasicMinimalPluginContext.configureServer (file://@@/node_modules/@cloudflare/vite-plugin/dist/index.js:17540:11)
    at async _createServer (file://@@/node_modules/vite/dist/node/chunks/node.js:26521:86)
    at async restartServer (file://@@/node_modules/vite/dist/node/chunks/node.js:26686:16)`
}

Please provide any relevant error logs

No response

Metadata

Metadata

Labels

awaiting Cloudflare responseAwaiting response from workers-sdk maintainer teamvite-pluginRelating to the `@cloudflare/vite-plugin` package

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions