Skip to content

http2: shouldUpgradeCallback is not a function with allowHTTP1 in v22.21.0 #60336

@ysgk

Description

@ysgk

Version

v22.21.0

Platform

Darwin MAC-202307007 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020 arm64

Subsystem

http2

What steps will reproduce the bug?

I'm experiencing this issue through Vite 7.1.11 with HTTPS options.

vite.config.ts:

import * as fs from 'node:fs'
import { defineConfig } from 'vitest/config'

export default defineConfig({
  server: {
    https: {
        key: fs.readFileSync('./key.pem'),
        cert: fs.readFileSync('./cert.pem'),
    },
  },
})

Steps:

  1. Generate a self-signed certificate:
  2. Run npx vite
  3. Access https://localhost:5173 in browser

Error:

    VITE v7.1.11  ready in 111 ms

    ➜  Local:   https://localhost:5173/
    ➜  Network: use --host to expose
  node:_http_server:1076
                    !!server.shouldUpgradeCallback(req);
                             ^

  TypeError: server.shouldUpgradeCallback is not a function
      at parserOnIncoming (node:_http_server:1076:28)
      at HTTPParser.parserOnHeadersComplete (node:_http_common:122:17)

  Node.js v22.21.0

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

The server should handle HTTP/1.1 Upgrade requests (like WebSocket handshake) without errors.

What do you see instead?

The server crashes immediately when the first HTTP/1.1 Upgrade request is received:

TypeError: server.shouldUpgradeCallback is not a function
    at parserOnIncoming (node:_http_server:1076:28)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:122:17)

The server terminates and the upgrade request is never processed.

Additional information

This works fine on Node.js v22.20.0 and below. The issue appeared after upgrading to v22.21.0, where PR #59824 was backported but the fix PR #59924 (which has dont-land-on-v22.x label) was not.

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