Skip to content

http2: end is emitted before error when destroying client streamΒ #39400

@szmarczak

Description

@szmarczak

Version

v16.4.2

Platform

Linux solus 5.13.1-187.current #1 SMP PREEMPT Wed Jul 7 19:52:26 UTC 2021 x86_64 GNU/Linux

Subsystem

http2

What steps will reproduce the bug?

import http2 from 'http2';
import stream from 'stream';

const session = http2.connect('https://petstore.swagger.io/v2/pet/findByStatus?status=available');
const request = session.request({
	':path': '/findByStatus?status=available',
	'x-trace-id': 'foo',
	'user-agent': 'foo-bar/baz, bash'
});

request.on('data', () => {
	request.destroy(new Error('error'));
});

request.on('end', () => {
	console.log('end');
});

request.end();

await stream.promises.pipeline(
	request,
	new stream.PassThrough()
);

console.log('success');

session.close();

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Error: error
    at ClientHttp2Stream.<anonymous> (file:///home/szm/Desktop/got/demo.js:12:18)
    at ClientHttp2Stream.emit (node:events:406:35)
    at addChunk (node:internal/streams/readable:312:12)
    at readableAddChunk (node:internal/streams/readable:287:9)
    at ClientHttp2Stream.Readable.push (node:internal/streams/readable:226:10)
    at Http2Stream.onStreamRead (node:internal/stream_base_commons:190:23)

What do you see instead?

end
success

Additional information

Possibly related with #29929 or #35209

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.http2Issues or PRs related to the http2 subsystem.streamIssues and PRs related to the stream subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions