Open veinnotnice opened 1 day ago
I confirmed this workaround.
I tried without success to monkeypatch using something like:
import { getRequest as originalGetRequest } from '@sveltejs/kit/node';
// Overwrite the original function
export async function getRequest({ request, base, bodySizeLimit }) {
const filteredHeaders = {};
const isHttp2 = Object.keys(request.headers).some(key => key.startsWith(':'));
for (const [key, value] of Object.entries(request.headers)) {
if (typeof value === 'string') {
// Remove pseudo-headers if it's an HTTP/2 request
if (isHttp2 && key.startsWith(':')) {
continue;
}
filteredHeaders[key] = value;
}
}
return new Request(base + request.url, {
// @ts-expect-error
duplex: 'half',
method: request.method,
headers: filteredHeaders,
body:
request.method === 'GET' || request.method === 'HEAD'
? undefined
: get_raw_body(request, bodySizeLimit)
});
}
// Patch the original module
import * as originalModule from '@sveltejs/kit/node';
originalModule.getRequest = getRequest;
Then in +layout.server.ts
import '../../src/patchRequest.js';
Without this, I cannot run node v20.x.
Describe the bug
Issue Description:
It seems that adding the
proxy
attribute to yourvite.config.ts
file, even if left empty, causes Vite to disable HTTP/2 support for your development server. This is problematic because your project relies on HTTP/2 for certain functionalities. Even though you don't actually need a proxy, you're forced to include it to get the development server to start, but this inclusion then breaks a key part of your project.Analysis:
symbol
tostring
withinundici
.getRequest
function innode_modules
, specifically within@sveltejs/kit
.proxy
object in thevite.config.ts
enables HTTP/2, which seems to be triggering an unexpected code path.Temporary Fix:
I modified the
getRequest
function withinnode_modules
as follows:Expected Behavior:
Thank you for your help and consideration!
Reproduction
Use
@sveltejs/kit
with Vite invite.config.ts
:Run the project and open it in a browser.
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response