Skip to content

http2: close not emitted when receiving RST_STREAM after DATA #27863

Description

@mildsunrise
  • Version: latest master
  • Platform: Linux 4.4.0-142-generic 168-Ubuntu SMP Wed Jan 16 2019 x86_64 GNU/Linux
  • Subsystem: http2
const server = http2.createServer();
server.on('stream', (stream) => {
  stream.respond();
  stream.write('test');
  // Wait for DATA to be sent, then send RST_STREAM
  setTimeout(() => stream.close(), 200);
});

server.listen(() => {
  const client = http2.connect({ protocol: 'http:', ...server.address() });
  const req = client.request({ ':path': '/' });
  req.end();
  req.on('close', () => {
    // Never called
  });
});

I can verify that RST_STREAM is sent to the client, but close is never emitted. Is this expected?
If the write is removed, close is emitted.

Activity

  1. added
    http2Issues and PRs related to the http2 subsystem.
    on May 25, 2019
  2. mildsunrise commented on May 26, 2019

    @mildsunrise
    ContributorAuthor

    I have bisected this to #17406, to the second commit.
    Relevant diffs: lib/internal/http2/core.js and src/node_http2.cc

  3. mildsunrise commented on May 26, 2019

    @mildsunrise
    ContributorAuthor

    ...I feel a bit stupid. After #17406, the stream isn't destroyed immediately upon receiving an RST_STREAM, it's destroyed after all data has been consumed. Hence, doing req.resume() on the above example makes it emit the close event.

    I think we should at least clarify the docs. Also, test-http2-large-write-destroy.js should be corrected to add req.resume(), unless I'm missing something.

  4. lpinca commented on May 26, 2019

    @lpinca
    Member

    Also, test-http2-large-write-destroy.js should be corrected to add req.resume(), unless I'm missing something.

    Yes, seems correct to me.

  5. Trott commented on May 28, 2019

    @Trott
    Member

    Fixed in 42d8011

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