epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.47k stars 368 forks source link

dev-server does not restarts when it crashes #690

Closed fredericrous closed 5 months ago

fredericrous commented 6 months ago

I'm using a monorepo with pnpm. My Epic Stack project has a dependency on another workspace

  // package.json
  "my-react-lib": "workspace:*"

when my-react-lib gets rebuilt, the built artefact gets removed for a sec and the new one replaces it

when this happens, dev-server crashes with an error that looks something like

[vite] Error when evaluating SSR module virtual:remix/server-build: failed to import "app/routes/my-page.tsx"
Error: Failed to load url /@fs/monorepo/my-project/dist/my-react-lib.js (resolved id:  /@fs/monorepo/my-project/dist/my-react-lib.js ) in  /@fs/monorepo/my-epic-stack-project/app/routes/my-page.tsx. Does the file exist?
    at loadAndTransform (file:///monorepo/node_modules/.pnpm/vite@5.1.5_@types+node@20.11.25/node_modules/vite/dist/node/chunks/dep-G-px366b.js:53634:21)
    at instantiateModule (file:///monorepo/node_modules/.pnpm/vite@5.1.5_@types+node@20.11.25/node_modules/vite/dist/node/chunks/dep-G-px366b.js:54656:10)

By it crashes, I mean, when I reload the browser to show my-page, chrome says This site can’t be reached ERR_CONNECTION_REFUSED

workaround: restart the dev-server manually: Ctrl+C, and then npm run dev

I tried to fix this issue by myself but all my attempts have failed so far

koikar commented 6 months ago

I am experiencing similar issues with syntax errors. While editing files and using the vs-code autosave feature, my dev server constantly crashes.

[vite] Internal server error: Transform failed with 1 error

I am wondering if there is a better solution than just turning off the autosave feature. Has anyone found a solution?

simonszalai commented 6 months ago

It's the same issue as #638, there is a pretty decent solution written there. It's not 100%, but it can work.

kentcdodds commented 5 months ago

Closing this in favor of #638