Skip to content

TypeError: Headers.append: ":method" is an invalid header name #528

@morganwalkup

Description

@morganwalkup

Suddenly running into a TypeError for HTTP2 headers after updating to the latest @netlify/vite-plugin versions. This crashes the process and prevents my Netlify project from running locally.

node:internal/deps/undici/undici:4282
      return new TypeError(`${message.header}: ${message.message}`);
             ^

TypeError: Headers.append: ":method" is an invalid header name.
    at webidl.errors.exception (node:internal/deps/undici/undici:4282:14)
    at webidl.errors.invalidArgument (node:internal/deps/undici/undici:4293:28)
    at appendHeader (node:internal/deps/undici/undici:9464:29)
    at fill (node:internal/deps/undici/undici:9445:11)
    at new Request (node:internal/deps/undici/undici:10617:13)
    at getNormalizedRequestFromNodeRequest (file:///Users/morgan.walkup/Repos/frontend/node_modules/@netlify/dev/dist/main.js:205:10)
    at NetlifyDev.handleAndIntrospectNodeRequest (file:///Users/morgan.walkup/Repos/frontend/node_modules/@netlify/dev/dist/main.js:473:26)
    at async netlifyPreMiddleware (file:///Users/morgan.walkup/Repos/frontend/node_modules/@netlify/vite-plugin/dist/main.js:139:26)

Node.js v24.11.0

If I manually edit the package within my node_modules folder, I can get things running again by excluding HTTP2 headers in this block of code:

@netlify/dev/dist/main.js

// src/lib/reqres.ts
import { Readable } from "stream";
var normalizeHeaders = (headers) => {
  const result = [];
  for (const [key, value] of Object.entries(headers)) {
    // Skip HTTP/2 pseudo-headers (headers starting with ':')
    if (key.startsWith(':')) {
      continue;
    }
    // Remaining code is unchanged
    if (Array.isArray(value)) {
      result.push([key, value.join(",")]);
    } else if (typeof value === "string") {
      result.push([key, value]);
    }
  }
  return result;
};

I think a small change in src/lib/reqres.ts is all that's needed here.

PR here: #529

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions