react-router icon indicating copy to clipboard operation
react-router copied to clipboard

Occulted Vite errors in dev mode Cloudflare - Error running module "

Open tavoyne opened this issue 4 months ago • 10 comments

Reproduction

  1. Start an RR app using the Cloudflare template:
npx create-react-router@latest --template remix-run/react-router-templates/cloudflare
  1. Open /app/routes/home.tsx.

  2. Change an import path to an intentionally incorrect one ("../welcome/welcome" → "/blabla").

  3. Start the dev server.

npm run dev
  1. Open http://localhost:5173/

System Info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M3
  Memory: 261.56 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node
  npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm
Browsers:
  Chrome: 139.0.7258.68
  Safari: 17.5
npmPackages:
  @react-router/dev: ^7.7.1 => 7.8.0 
  react-router: ^7.7.1 => 7.8.0 
  vite: ^6.3.3 => 6.3.5

Used Package Manager

npm

Expected Behavior

I'm expecting the actual build error to be reported:

Image

Actual Behavior

But I get this instead:

Image

Note: if you launch the dev server before changing the import path, it will surface the right error until you reload the page or get a new HMR update.

tavoyne avatar Aug 14 '25 13:08 tavoyne

Also, I noticed the template is using the unstable_viteEnvironmentApi flag. Might this be the issue?

Shouldn't the default template only rely on stable APIs, given that it's the source of truth and people expect it to work in production?

tavoyne avatar Aug 14 '25 15:08 tavoyne

I have this same error, and it makes development quite hard, as you can have a small typo but you don't know where's the issue.

fprl avatar Aug 31 '25 16:08 fprl

+1 makes development impossible

0ctan33 avatar Sep 04 '25 02:09 0ctan33

Also, I noticed the template is using the unstable_viteEnvironmentApi flag. Might this be the issue?

Shouldn't the default template only rely on stable APIs, given that it's the source of truth and people expect it to work in production?

The Cloudflare Vite plugin relies on Vite env api so RR needs to use it too

Note the Vite api is stable, what's unstable is the support in RR plugin

sergiodxa avatar Sep 04 '25 16:09 sergiodxa

I got the error a few days ago, but I think the issue is not in RR but in the CF plugin

sergiodxa avatar Sep 04 '25 16:09 sergiodxa

Same issue. It's making dev extremely difficult as theres no pointers to where the error is 😭

There is an open issue here

lewsmith avatar Sep 04 '25 16:09 lewsmith

I got the error a few days ago, but I think the issue is not in RR but in the CF plugin

Yes it seems like - it’s thrown from the CF plugin code.

tavoyne avatar Sep 04 '25 21:09 tavoyne

As a workaround you can build the app for prod and at least it’ll surface the error

tavoyne avatar Sep 04 '25 21:09 tavoyne

@tavoyne Good trick, thanks.

CaptainTrojan avatar Sep 05 '25 13:09 CaptainTrojan

The update in the Cloudflare Vite plugin should be almost available😄

https://github.com/cloudflare/workers-sdk/pull/10655

Update: fix was released https://github.com/cloudflare/workers-sdk/releases/tag/%40cloudflare/vite-plugin%401.13.2

RaphaelBronsveld avatar Sep 15 '25 21:09 RaphaelBronsveld