Comments (4)
Since this is hosted at the same port as the rest of the application. How would it work if the application had it's own WebSocket connection that it wanted to maintain? Wouldn't they conflict?
Yeah, that could be a concern, but maybe it's still possible to get around by setting server.hmr.path
to not conflict with your app's websocket path?
vite/packages/vite/src/node/server/ws.ts
Line 116 in 37190af
I tested your reproduction and I can confirm the issue, but it feels like a minor paper cut with very specific conditions.
Also I wonder if this is more like a problem of Vite's client-side websocket failure robustness. See for example:
from vite.
This is an Remix app hosted in Express, so not actually using the Vite dev server, just the HMR server
Can you provide a reproduction to show how the issue look like?
It's not entirely clear that how you setup coop/coep headers on Remix express, so providing that would probably help.
You might be able to avoid this issue by passing your own node server to server.hmr.server
(for example, something like I suggested for Remix Vite https setup long time ago https://github.com/hi-ogawa/test-remix-vite-express-https/blob/06da66d41950b8b0b3014f4f841d07e6fcffc7bf/server.mjs#L34), but I might be totally misunderstanding the issue.
Starting from their express template https://github.com/remix-run/remix/tree/main/templates/express, this is what I imagined would help https://stackblitz.com/edit/github-1jwsyy?file=server.js
from vite.
Here is a demonstration of the way I setup my headers and how the problem manifests: https://github.com/ngbrown/remix-vite-16536
from vite.
@hi-ogawa - I tried to change the server.js
file with the way you passed server
into the Vite hmr
property, it does work by re-using the same server instance as the rest of the application, but I had a few questions:
Wouldn't it be better to have a separate port like HMR is expected to have?Sharing the same port is how the default Remix template works.- Since this is hosted at the same port as the rest of the application. How would it work if the application had it's own WebSocket connection that it wanted to maintain? Wouldn't they conflict?
I've updated my suggested solution with the headers I would like to set, assuming the HMR server is on a different port.
from vite.
Related Issues (20)
- Add the ability to prevent transforming some assets files HOT 1
- The esbuild-transpile error occurred when vite5.0+ build HOT 1
- Allow to specify resolve.alias or virtual module based on entry HOT 7
- Vite config loadEnv exposing all envs to frontend. HOT 7
- AsideSponsors is outdated HOT 1
- Build --watch need HMR HOT 2
- Proxy processing OPTIONS requests will always return a 204 response HOT 3
- Vite `--watch` mode break after first change (Vite v.5.X) HOT 2
- Sourcemap for "xxx" points to missing source files, while inject `script.src` to index.html HOT 3
- Uncaught TypeError: t._reverse is not a function HOT 6
- ReferenceError: Cannot access 'q' before initializatio
- [vite] Internal server error: Missing "./../etc/passwd" export in "vite" package
- vue3 import() import variables HOT 1
- package.json - JSON does not support comments HOT 1
- Symlink only supports set of libararies HOT 2
- Service worker files do not get chunked HOT 2
- Infinite HMR loop if circular dep calls `import.meta.hot.invalidate()`
- when upgrade NodeJS up to v20+ local proxy not work HOT 1
- The `proxyGuardOnlyEsm` does not work consistently HOT 2
- Missmatch between dev / build for typescript files with ?url HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite.