Skip to content

undici's new Request is incompatible with HTTP/2 requests #11365

@Elsoberanold

Description

@Elsoberanold

Describe the bug

After migration to SvelteKit 2 serving throw https just stopped working. It does not crash on execution but at the moment we reach exposed endpoint it returns the following error:

TypeError: Headers.append: ":method" is an invalid header name.
    at webidl.errors.exception (node:internal/deps/undici/undici:1635:14)
    at webidl.errors.invalidArgument (node:internal/deps/undici/undici:1646:28)
    at appendHeader (node:internal/deps/undici/undici:2052:29)
    at fill (node:internal/deps/undici/undici:2038:11)
    at new Request (node:internal/deps/undici/undici:6151:13)
    at getRequest (file:///Users/gfbatista/Projects/skedmill_ts/frontend/node_modules/@sveltejs/kit/src/exports/node/index.js:101:9)
    at file:///Users/gfbatista/Projects/skedmill_ts/frontend/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:475:27

Reproduction

This error can be reproduced by starting a new SvelteKit 2 project and changing vite.config.ts accordingly with documentation provided here: https://vitejs.dev/guide/migration#remove-https-flag-and-https-true . I have tried to use https://github.com/vitejs/vite-plugin-basic-ssl and https://github.com/liuweiGL/vite-plugin-mkcert both with same result.
vite.config.ts file:

import { sveltekit } from '@sveltejs/kit/vite';
import basicSsl from '@vitejs/plugin-basic-ssl'
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [basicSsl(), sveltekit()]
});

### Logs

```Shell
TypeError: Headers.append: ":method" is an invalid header name.
    at webidl.errors.exception (node:internal/deps/undici/undici:1635:14)
    at webidl.errors.invalidArgument (node:internal/deps/undici/undici:1646:28)
    at appendHeader (node:internal/deps/undici/undici:2052:29)
    at fill (node:internal/deps/undici/undici:2038:11)
    at new Request (node:internal/deps/undici/undici:6151:13)
    at getRequest (file:///.../node_modules/@sveltejs/kit/src/exports/node/index.js:101:9)
    at file:///.../node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:475:27


### System Info

```Shell
System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 130.47 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.4.0 - ~/.nvm/versions/node/v21.4.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v21.4.0/bin/npm
    pnpm: 7.27.0 - ~/.nvm/versions/node/v18.12.1/bin/pnpm
    bun: 1.0.13 - ~/.bun/bin/bun
  Browsers:
    Safari: 17.2
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.0.0 
    @sveltejs/kit: ^2.0.0 => 2.0.0 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1 
    svelte: ^4.2.7 => 4.2.8 
    vite: ^5.0.0 => 5.0.10

Severity

serious, but I can work around it

Additional Information

I think that should be a resurgence of this issue: #3479
I have tryed this work around and it works:

vite.config.ts:

import basicSsl from '@vitejs/plugin-basic-ssl'
import { defineConfig } from 'vite';

export default defineConfig({
	server: {
		proxy: {}
	},
	plugins: [basicSsl(), sveltekit()]
});```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions