-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy on hmr dev server #16536
Comments
Can you provide a reproduction to show how the issue look like? You might be able to avoid this issue by passing your own node server to 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 |
Here is a demonstration of the way I setup my headers and how the problem manifests: https://github.com/ngbrown/remix-vite-16536 |
@hi-ogawa - I tried to change the
I've updated my suggested solution with the headers I would like to set, assuming the HMR server is on a different port. |
Yeah, that could be a concern, but maybe it's still possible to get around by setting 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. |
Hello! My users are running into this problem unfortunately when using Triplex (a visual editor, see: https://triplex.dev). Vite is used for the local development backend. Triplex is available as a standalone Electron app as well as an extension inside VS Code. I've gotten feedback around the editor becoming unresponsive after their OS sleeps, which e.g. happens immediately when closing a macOS lapto. When this happens they're forced to close the editor and re-open. In the Electron app I've been able to work around the problem by forcing headers onto all web server responses. When the OS goes to sleep and is woken up they can continue their session right where they left off! Unfortunately I don't have this flexibility in the VS Code extension, so having the ability to set the headers on the HMR response would be great. I saw the |
Description
Like #3909 but for the HMR dev server. During development I have the COEP header with a value of
require-corp
to access certain features likeSharedArrayBuffer
objects orPerformance.now()
with unthrottled timers. (cross-origin isolated features).From MDN:
The problem is that when the server is restarting, the HMR WebSocket connection switches to polling on the HMR port ("[vite] server connection lost. polling for restart..."). However, the browser is giving this error:
The resource never connects and the page doesn't automatically reload. I have to manually reload the page so it can establish the WebSocket connection. This also happens when
vite.config.ts
changes.I tried setting the
server.headers
option, but it doesn't affect the HMR server endpoint. (This is an Remix app hosted in Express, so not actually using the Vite dev server, just the HMR server).The
server.hmr.server
option seems to take a class instance and there is noserver.hmr.headers
option.Suggested solution
Add a
server.hmr.headers
option like was implemented in #5580.The headers I need to set would look like this:
Alternative
I could remove the Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy headers while in development, but the cross-origin isolated browser features would be disabled.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: