Skip to content

Conversation

edmundhung
Copy link
Member

@edmundhung edmundhung commented Oct 7, 2025

Fixes #10404.
Closes #10841.

This fixes an issue using the cloudflare vite plugin with React Router which shows Internal server error: Miniflare not defined when you update the wrangler config.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: no changes on wrangler

Copy link

changeset-bot bot commented Oct 7, 2025

🦋 Changeset detected

Latest commit: 9af7c62

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

Copy link

pkg-pr-new bot commented Oct 7, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 9af7c62

@edmundhung edmundhung force-pushed the edmundhung/vite-restart-issue branch 2 times, most recently from 1be2ffe to e8ce041 Compare October 7, 2025 12:51
@petebacondarwin
Copy link
Contributor

I see a lot of CI failures. I think this is expected as I seem to remember that it was important that this variable was confined to the scope of the plugin for scenarios (e.g. testing) where the plugin was recreated in-process.

Can you describe how the error is actually occuring?
What is react-router doing that is different to other scenarios that don't have errors?

@edmundhung
Copy link
Member Author

I see a lot of CI failures. I think this is expected as I seem to remember that it was important that this variable was confined to the scope of the plugin for scenarios (e.g. testing) where the plugin was recreated in-process.

Can you describe how the error is actually occuring? What is react-router doing that is different to other scenarios that don't have errors?

It works fine if you run the new react router playground directly. The CI error is mainly caused by how we start a vite server manually instead of using the React Router CLI.

Let's discuss a bit more next week 👍🏼

@edmundhung edmundhung force-pushed the edmundhung/vite-restart-issue branch 2 times, most recently from 78e13f4 to 3c61f13 Compare October 15, 2025 10:54
@edmundhung edmundhung force-pushed the edmundhung/vite-restart-issue branch from 3c61f13 to eed47a8 Compare October 15, 2025 11:03
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Oct 15, 2025
@edmundhung edmundhung marked this pull request as ready for review October 15, 2025 20:10
@edmundhung edmundhung requested review from a team as code owners October 15, 2025 20:10

fix: track server restart in module scope

When using `@cloudflare/vite-plugin` with React Router, miniflare might be disposed during restart. This change makes sure to track when the dev server restart in module scope to avoid unexpected behavior.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When using `@cloudflare/vite-plugin` with React Router, miniflare might be disposed during restart. This change makes sure to track when the dev server restart in module scope to avoid unexpected behavior.
When using `@cloudflare/vite-plugin` with React Router, miniflare might be disposed during restart. This change makes sure to track when the dev server restarts in the module scope to avoid unexpected behavior.

@edmundhung edmundhung merged commit e2809b5 into main Oct 16, 2025
35 of 36 checks passed
@edmundhung edmundhung deleted the edmundhung/vite-restart-issue branch October 16, 2025 10:45
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Oct 16, 2025
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.

🐛 BUG:Server restart fails with 'Miniflare not defined' with the react-router template

2 participants