Skip to content
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

Nested HTTP/2 pushStream fails with error #19095

Closed
robbie-mac opened this issue Mar 2, 2018 · 6 comments
Closed

Nested HTTP/2 pushStream fails with error #19095

robbie-mac opened this issue Mar 2, 2018 · 6 comments
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@robbie-mac
Copy link

Version: 9.7.1
Platform: 64-bit (Windows)
Subsystem: http/2

//server = http2.createSecureServer(); init code removed for brevity
server.addListener('stream', function (stream, headers) {
    let resourcePath = path.join(serverRootPath, headers[HTTP2_HEADER_PATH]);
    stream.respondWithFile(resourcePath, {
        'content-type': mimeTypes.get(resourcePath.match(mimeRegExp)[0]),
    });
    let pushResourcePath = <full path to pushed resource>;
    stream.pushStream({ ':path': pushResourcePath }, { 'parent': stream.id }, (err, stream, headers) => {
        stream.respondWithFile(path.join(serverRoot, pushResourcePath), {
            'content-type': mimeTypes.get(path.join(serverRoot, pushResourcePath).match(mimeRegExp)[0]),
        });
        let subPushResourcePath = <full path to sub pushed resource>;
        stream.pushStream({ ':path': subPushResourcePath }, { 'parent': stream.id }, (err, stream, headers) => {
            stream.respondWithFile(path.join(serverRoot, subPushResourcePath), {
                'content-type': mimeTypes.get(path.join(serverRoot, subPushResourcePath).match(mimeRegExp)[0]),
            });
        });
    });
}); 

The nested pushStream callback argument (err) is populated with this:

{ Error [ERR_HTTP2_ERROR]: Invalid argument
at ServerHttp2Stream.pushStream (internal/http2/core.js:2095:17)
at file:///D:/http2_experimental_server/src/server.mjs:106:24
at process._tickCallback (internal/process/next_tick.js:114:19)
code: 'ERR_HTTP2_ERROR',
name: 'Error [ERR_HTTP2_ERROR]',
errno: -501 }
@jasnell
Copy link
Member

jasnell commented Mar 2, 2018

A push stream cannot be the parent of another push stream. Specifically, a server is only permitted to send a PUSH_PROMISE frame on a client initiated stream.

@jasnell
Copy link
Member

jasnell commented Mar 2, 2018

A better error message here would be good.

@robbie-mac
Copy link
Author

I figured that would be the case but, although I don't show it, after checking the value of pushallowed which came back true, I figured why not try.

@robbie-mac
Copy link
Author

Thanks for the quick response though. I can quit banging my head against that brick wall. @jasnell Should I leave this open or close the issue?

@jasnell
Copy link
Member

jasnell commented Mar 3, 2018

Let's leave this open. Some API and doc improvements would be worthwhile

@trivikr trivikr added the http2 Issues or PRs related to the http2 subsystem. label Mar 25, 2018
jasnell added a commit to jasnell/node that referenced this issue Aug 10, 2018
@robbie-mac
Copy link
Author

@jasnell Thanks, I ran into this issue again just the other day. You're a rockstar!!

rvagg pushed a commit that referenced this issue Aug 15, 2018
Fixes: #19095

PR-URL: #22245
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
kjin pushed a commit to kjin/node that referenced this issue Sep 25, 2018
Fixes: nodejs#19095

PR-URL: nodejs#22245
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
kjin pushed a commit to kjin/node that referenced this issue Oct 16, 2018
Fixes: nodejs#19095

PR-URL: nodejs#22245
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
BethGriggs pushed a commit that referenced this issue Oct 17, 2018
Fixes: #19095

Backport-PR-URL: #22850
PR-URL: #22245
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants