-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
#844 fix for SSL HMR websockets #1517
Conversation
Is it normal if the netlify tests were cancelled? There were no changes in the output build, since this change only affects dev and preview, when the -H or --host parameters are supplied. |
don't worry about the Netlify tests. I think they only run for changes to the Netlify adapter I was having a little bit of a hard time following your explanation, but I would say to go ahead and switch the order. Putting in a dummy handler and then switching it out later make it harder to follow the code. It also seems to me like it'd make things less likely to work as expected because what if a request comes in while the dummy handler is installed |
Good idea. Code changed, tested locally in dev & preview using demo app. I think I was just being too cautious -- not wanting to reorder code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for being patient with this one and following up with the Vite team about getting it documented
@benmccann a few people on discord are reporting identical errors after the 114 update. It's been reported that switching back to 113 has fixed it. Wondering if this PR was the culprit? Here are my Netlify build logs with 115 for instance:
Messages:
Here's the update branch on my repo that was failing builds on Netlify: Happy to provide more details or open an issue if you think it's needed. |
I tried downgrading to Kit 113 on its own, and still got the error. The error went away when I downgraded Vite to 2.3.6 |
Hmm. Perhaps @rixo or @dominikg know something about |
I cloned your repro -- dev, build and preview work with SvelteKit 1.0.0-next.115 and Vite 2.3.7. However "start" has been renamed to "preview", which tells me that you haven't updated your package.json, and possibly some other configuration(s) that have breaking changes since your previous SvelteKit version. You might want to create a new SvelteKit demo project, and compare package.json, svelte.config.js, and any other config files, along with your library structure. #844 only affects dev and preview modes. Also, Netlify deployments shouldn't even reference HMR. To be honest, I don't know anything about Netlify. |
Thanks for the tips @JBusillo. I've gotten it to run by first adopting all the config file changes, then I needed to add
If this isn't an isolated issue, it might be worth adding a FAQ to the Netlify adapter that this file is needed, or even just add it to the skeleton project if it doesn't cause any harm perhaps? Regardless, after this troubleshooting and that extra step for the Node version, it's now working for me. |
The adapter should be able to spit out a |
This is a proposed fix to Issue #844
Currently, when the dev server is invoked using the https option (-H or --https) using an unsigned certificate, the Vite HMR web client cannot connect to the server using its 'wss' url. It retries incessantly. Browsers will reject the connection, as the user can't 'approve' the possibly unsafe site.
To correct this, the web socket should 'piggy-back' onto the https server. Thus, when the user selects 'Proceed' from the 'Your connection is not private' dialog, both https and wss connections will be deemed valid. Vite manages the wss connection upgrade from this point forward.
The get_server function must be called before vite.createServer, since the server reference must be available to vite.createServer.
Perhaps I'm being too cautious, but I didn't want to switch the order of the current vite.createServer block (of code) with the get_server block. The dev server isn't ready to process requests until vite.createServer is complete. Thus, you'll see that I coded a dummy handler that is eventually replaced once vite.createServer has completed.
I ran the tests within kit (pnpm run test), and ran tests on both 'dev' and 'preview' with all combinations of the --https and --host options.
This is my first pull request ever -- please don't be too hard on me.