Skip to content

Nested HTTP/2 pushStream fails with error #19095

Description

@robbie-mac

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 }

Activity

  1. jasnell commented on Mar 2, 2018

    @jasnell
    Member

    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.

  2. jasnell commented on Mar 2, 2018

    @jasnell
    Member

    A better error message here would be good.

  3. robbie-mac commented on Mar 3, 2018

    @robbie-mac
    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.

  4. robbie-mac commented on Mar 3, 2018

    @robbie-mac
    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?

  5. jasnell commented on Mar 3, 2018

    @jasnell
    Member

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

  6. added
    http2Issues and PRs related to the http2 subsystem.
    on Mar 25, 2018
  7. robbie-mac commented on Aug 14, 2018

    @robbie-mac
    Author

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

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

    http2Issues and PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions