express: Node http2 - cannot read this.socket.readable

Testing node’s new http2 native module I couldn’t get express to serve requests over http2, Using node master build with --expose-http2 flag:

const express = require('express');

const app = express();

app.get('/express', (req, res) => {
  res.send('Hello from express');
});

const server = http2.createSecureServer({
  key,
  cert
}, app);

When requesting /express the server crashed with the following error:

(node:80731) ExperimentalWarning: The http2 module is an experimental API.
_http_incoming.js:104
  if (this.socket.readable)
                 ^

TypeError: Cannot read property 'readable' of undefined
    at IncomingMessage._read (_http_incoming.js:104:18)
    at IncomingMessage.Readable.read (_stream_readable.js:431:10)
    at IncomingMessage.read (_http_incoming.js:96:15)
    at resume_ (_stream_readable.js:811:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 26 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Still not working

I would love to help investigate and assist with all the investigation/integration between the new http2 and express, however I would need guidance on how/where to start. @jasnell

I am still seeing this issue with Node v10.14.1 and express@4.16.4. Is there any timeline on resolving this problem?

Amusing…

Http2ServerRequest defines getter for ‘url’ property as return this.path, express request.js defines ‘path’ as

return parse(this).pathname;

which calls - you guessed it, request.url 😃 resulting in stack overflow, when commenting out the ‘path’ getter in request.js I got a response.

Not working on Node 14.5.0, express 4.17.1

Same here, trying to serve up a react app over http/2 using the native http module from node.

I am using "express": "4.17.1" on Node v12.13.0

Any ideas ?

Express does seem to have an open PR for this in version 5.0. Until then, I have created a workaround as a package(https://www.npmjs.com/package/http2-express-bridge). It worked perfectly on my application.

If anyone wants to experiment with it, do check it out.

Tested on node-14.15.5, express- 4.17.1