Skip to content

Fix potential EBADF error when restarting workerd process in Miniflare#12025

Merged
petebacondarwin merged 2 commits intomainfrom
fix-miniflare-runtime-ebadf-on-restart
Feb 11, 2026
Merged

Fix potential EBADF error when restarting workerd process in Miniflare#12025
petebacondarwin merged 2 commits intomainfrom
fix-miniflare-runtime-ebadf-on-restart

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Jan 21, 2026

Explicitly destroy all stdio streams (stdin, stdout, stderr, and control pipe) before killing the workerd process in Runtime#dispose(). This ensures file descriptors are properly released before spawning a new process, preventing EBADF errors during rapid restarts.

The original issue was not able to provide a reproduction that we could test so this PR is speculative.

Fixes #11675


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bug fix

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: f97d99b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12025

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12025

miniflare

npm i https://pkg.pr.new/miniflare@12025

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12025

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12025

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12025

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12025

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12025

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12025

wrangler

npm i https://pkg.pr.new/wrangler@12025

commit: f97d99b

@petebacondarwin petebacondarwin force-pushed the fix-miniflare-runtime-ebadf-on-restart branch from d9ed3ad to 4e3ee2d Compare February 3, 2026 16:39
@petebacondarwin petebacondarwin marked this pull request as ready for review February 3, 2026 16:39
@petebacondarwin petebacondarwin requested a review from a team as a code owner February 3, 2026 16:40
@claude
Copy link
Contributor

claude bot commented Feb 3, 2026

Claude finished @petebacondarwin's task —— View job


Changeset Review

✅ All changesets look good

The changeset for this PR follows all guidelines:

  • ✅ Correct version type (patch for a bug fix)
  • ✅ Clear, descriptive title and body explaining the issue and fix
  • ✅ No h1/h2/h3 headers used
  • ✅ Proper package reference (miniflare)
  • ✅ Well-formatted with appropriate technical detail

Cuteness Report: This is... an orange dot. Might be a distant planet or maybe a freckle with stage presence. Either way, not really delivering on the animal content. Still bold enough to show up though. 6/10 for effort.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

Explicitly destroy all stdio streams (stdin, stdout, stderr, and control
pipe) before killing the workerd process in Runtime#dispose(). This
ensures file descriptors are properly released before spawning a new
process, preventing EBADF errors during rapid restarts.

Fixes #11675
@petebacondarwin petebacondarwin force-pushed the fix-miniflare-runtime-ebadf-on-restart branch from 4e3ee2d to f97d99b Compare February 11, 2026 11:47
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 11, 2026
@petebacondarwin petebacondarwin merged commit d06ad09 into main Feb 11, 2026
36 checks passed
@petebacondarwin petebacondarwin deleted the fix-miniflare-runtime-ebadf-on-restart branch February 11, 2026 15:40
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

EBADF thrown when restarting workerd on vite server restart

3 participants