Skip to content

express crashing when using node internal http2 module on sending any request from client #6580

Closed

Description

@Thyran

Environment information

Version: 5.*

Platform:
Linux d176f8ed3db8 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux (Docker image from node:23-slim),
Microsoft Windows NT 10.0.19045.0 x64

Node.js version:
Linux: 23.11, 24.2
Windows: 22.12

Any other relevant information:
Error code:

node:events:502
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read properties of undefined (reading 'readable')
    at IncomingMessage._read (node:_http_incoming:211:19)
    at Readable.read (node:internal/streams/readable:739:12)
    at resume_ (node:internal/streams/readable:1257:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on IncomingMessage instance at:
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at errorOrDestroy (node:internal/streams/destroy:239:7)
    at Readable.read (node:internal/streams/readable:741:7)
    at resume_ (node:internal/streams/readable:1257:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Error persists even without using http2-express-bridge

What steps will reproduce the bug?

  1. Install express and http2-express-bridge dependency with npm
  2. Generate ssl key and cert file with openssl directly or using wsl
  3. Write index.mjs like
import fs from "fs";
import path from "path";
import http2 from "http2";
import express from "express";
import http2Express from "http2-express-bridge";

const app = http2Express(express);
const tlsOptions = {
    key: fs.readFileSync(path.join("certs", "ssl.key")),
    cert: fs.readFileSync(path.join("certs", "ssl.crt")),
};

app.get("/", function(req, res) {
    res.send("Hello World");
});

const server = http2.createSecureServer(tlsOptions, app);
server.listen(8080, () => { console.log("Server listening on port 8080"); });
  1. Add index.mjs as main script in package.json
  2. Run with node .
  3. Navigate to https://localhost:8080 in browser

Activity

  1. added theissue type on Jun 18, 2025
  2. krzysdz commented on Jun 18, 2025

    @krzysdz
    Contributor

    Express does not support HTTP/2 (see #5462). The error caused by http2-express-bridge has been reported in the package's repository (rahulramesha/http2-express-bridge#11), but it looks like that project has not been updated in a long time and is abandoned by its author.

  3. Thyran commented on Jun 18, 2025

    @Thyran
    Author

    I think I found the cause of the error.

    The function application.lazyrouter was removed with version 5 which the http2 bridge used to hook prototype overwriting for Http2ServerRequest and -Response on the req and res objects before forwarding them to the router api.

    Since the application.router is now not accessible anymore before initialization and prototype overwriting happens in application.handle is there any other way to set Http2ServerRequest and -Response prototypes for req and res objects before application.router.handle is called?

  4. locked and limited conversation to collaborators on Jun 21, 2025
  5. converted this issue into a discussion #6583 on Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions