New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node http2 - cannot read this.socket.readable #3388

Open
PiniH opened this Issue Aug 7, 2017 · 14 comments

Comments

Projects
None yet
6 participants
@PiniH
Copy link

PiniH commented Aug 7, 2017

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)
@dougwilson

This comment has been minimized.

Copy link
Member

dougwilson commented Aug 7, 2017

Hi @PiniH since it's experimental and just landed on master, I don't think we have done any research into what would need to be done to support it (either in Express.js or maybe bugs in Node.js experimental code). If you would like to help us and take on that task, that would be amazing :) !

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 7, 2017

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

@dougwilson

This comment has been minimized.

Copy link
Member

dougwilson commented Aug 7, 2017

Yea, I'd need some time to take a look at what is going on to get some pointers for where to start.

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 7, 2017

@dougwilson From quick investigation - the first problem starts in the init function, it sets the wrong prototype - it's Http2Request/Response all the way until

    setPrototypeOf(req, app.request)
    setPrototypeOf(res, app.response)

Not sure how to proceed now :)

@dougwilson

This comment has been minimized.

Copy link
Member

dougwilson commented Aug 7, 2017

Ah, the prototype. I guess that is different in the http2? Hmm, that sucks, because it is likely to be a large task to fix that. I would have assumed it wouldn't have been different, seeing as even the spdy module used those prototypes... and it's a third-party module that implemented http2 for a long time.

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 7, 2017

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 8, 2017

I played with it some more, exposing Http2ServerRequest and Http2ServerResponse from node internal http2 files, and used them in the request/response files, (also had to define an empty setter for response.statusMessage - as Http2ServerResponse only defines a getter but no setter).

I managed to get a response (404, but still a response ;) ) - it seems to fail at matching the route -

 express:router dispatching GET /express +38s
  express:router query  : /express +1m
  express:router expressInit  : /express +34s

it seems to fail at a stack error (but only on the third call - not sure what's up with that yet) on

// get pathname of request
    var path = getPathname(req);

It got the correct path 2 times and then got stackoverflow. Any idea where/how to proceed?

@benjamingr

This comment has been minimized.

Copy link

benjamingr commented Aug 8, 2017

What's path returned as, and what's getPathname doing?

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 8, 2017

From what I'm seeing, the getPathname is working properly, until the layer that's called expressInit is running (I guess that's an internal layer?), and then the getPathname fails with stackoverflow, will update soon with more details.

@PiniH

This comment has been minimized.

Copy link
Author

PiniH commented Aug 8, 2017

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.

@hansanghoon

This comment has been minimized.

Copy link

hansanghoon commented Jan 23, 2018

any progress so far? is there workaround without touching http2(or express) core?

@dougwilson

This comment has been minimized.

Copy link
Member

dougwilson commented Jan 24, 2018

Hi @hansanghoon all the work is happening in the linked PR: #3390

@expressjs expressjs deleted a comment from danielgindi Jul 5, 2018

shesek added a commit to shesek/spark-wallet that referenced this issue Sep 1, 2018

Work-in-progress HTTP2 support via "spdy" module
This works, but it looks like the "spdy" module (which, despite its name, also supports http2)
is not compatible with newer nodejs versions and should be avoided:
spdy-http2/node-spdy#333
webpack/webpack-dev-server#1451

Should eventually use nodejs's native http2 module, but it is currently incompatible with express:
expressjs/express#3388

Committing the changes to a branch and setting aside for now.

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Oct 31, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Oct 31, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
cherry pick of webpack@e97d345

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Oct 31, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
cherry pick of webpack@e97d345

This commit is in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Oct 31, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
cherry pick of webpack@e97d345

this issue was fixed is in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Oct 31, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
Ports fix for webpack#1449 to v2 branch
cherry pick of webpack@e97d345

this issue was fixed in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Nov 1, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
Ports fix for webpack#1449 to v2 branch
cherry pick of webpack@e97d345

this issue was fixed in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Nov 1, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
Ports fix for webpack#1449 to v2 branch
cherry pick of webpack@e97d345

this issue was fixed in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Nov 1, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
Ports fix for webpack#1449 to v2 branch
cherry pick of webpack@e97d345

this issue was fixed in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388

RohanBhanderi pushed a commit to RohanBhanderi/webpack-dev-server that referenced this issue Nov 1, 2018

Rohan Bhanderi
Fix server: don't use spdy on node >= v10.0.0
Ports fix for webpack#1449 to v2 branch
cherry pick of webpack@e97d345

this issue was fixed in webpack-dev-server v3 line, which requires webpack to be
upgraded to >= 4.0.0. This commit cherry picks the fix to v2 branch (on top of v2.11.3)
which does not require webpack to be upgraded to 4.0.0

`spdy` is effectively unmaintained, and as a consequence of an
implementation that extensively relies on Node’s non-public APIs, broken
on Node 10 and above. In those cases, only https will be used for now.
Once express supports Node's built-in HTTP/2 support, migrating over to
that should be the best way to go.

related issues:
nodejs/node#21665
nodejs/node#21665
webpack#1449
expressjs/express#3388
@glepsky

This comment has been minimized.

Copy link

glepsky commented Dec 10, 2018

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

@sci4me

This comment has been minimized.

Copy link

sci4me commented Feb 21, 2019

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

Same here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment