-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Not work with Node.js v21 when using https in dev server #15495
Comments
I think this is a way to be compatible with |
@XiSenao Could you please explain more details about this? The PR you linked was merged 2 years ago. |
I think it may be related to the changes in this logic( function isValidHTTPToken (characters) {
if (characters.length === 0) {
return false
}
for (let i = 0; i < characters.length; ++i) {
if (!isTokenCharCode(characters.charCodeAt(i))) {
return false
}
}
return true
} https://github.com/nodejs/node/blob/68c8472ed9edbf1d3fbb1e46cb65b678ee52312c/deps/undici/src/lib/fetch/util.js#L140-L150 It seems that |
@XiSenao do you know where we could fix to fix the issue? I'm slightly inclined to close this as there had always been issues with odd-numbered Node.js versions and often it's a Node.js bug instead. |
I missed the notification for this issue😂. Yes, I think Node is still in an unstable stage, and I may not be inclined to be compatible with unstable versions of Node. @bluwy |
FYI, Remix also had a similar story as sveltekit when adapting Vite's http2: Initially I suggested to strip out pseudo headers ( which I thought is necessary since Remix's Request/Response related polyfill (https://github.com/remix-run/web-std-io) didn't accept such headers at that time (in sveltekit case, I guess it was node-fetch polyfill). Since Remix's polyfill is opt-in, when disabling such polyfill, it's actually working since Node 18/20's global Request (which is essentially undici's Request) was accepting pseudo headers. So, eventually Remix team decided to follow that behavior in their polyfill as well: Apparently, Undici "fixed" this behavior in response to this issue and Node 21 is currently rejecting http2 pseudo header: Regardless of whether this strict behavior would land in stable node or not, personally I feel this is a framework concern than Vite itself since framework is the one converting from Node-style IncomingMessage class to Web/fetch-style Request class (also deciding whether polyfill Request or not). Btw, I made a little script to test node's http2 here https://github.com/hi-ogawa/repro-http2-pseudo-headers/blob/main/repro.mjs |
Yeah, the error was happening at this line and I also think this needs to be fixed on SvelteKit side. Although, I think we should fix the types of connect on our side, too. vite/packages/vite/src/node/http.ts Lines 117 to 118 in dbb2604
|
Describe the bug
The dev server always responds "Invalid request body"
The original issue can be found at sveltejs/kit#11213.
I believe the problem lies in the incompatibility between the vite dev server and HTTP/2, which is the default protocol when using HTTPS.
While many people only use HTTP on their dev servers to avoid this issue, we have specific cookie strategies that require both our dev server and production server to use HTTPS.
UPDATE: I recently upgraded to SvelteKit 2 (which is using Vite 5) and Node.js v21.5.0, the issue persists with a different error message:
Reproduction
https://github.com/hronro/vite-https-issue
Steps to reproduce
pnpm i
pnpm dev
System Info
System: OS: Linux 6.6 Arch Linux CPU: (14) x64 AMD Ryzen 7 5800X 8-Core Processor Memory: 26.50 GB / 27.41 GB Container: Yes Shell: 3.7.0 - /usr/bin/fish Binaries: Node: 21.5.0 - /usr/bin/node Yarn: 1.22.21 - /usr/bin/yarn npm: 10.2.5 - /usr/bin/npm pnpm: 8.13.1 - /usr/bin/pnpm npmPackages: vite: ^5.0.10 => 5.0.10
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: