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

end after write stops http2 stream with trailers ending #41898

Closed
davedoesdev opened this issue Feb 8, 2022 · 4 comments
Closed

end after write stops http2 stream with trailers ending #41898

davedoesdev opened this issue Feb 8, 2022 · 4 comments
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@davedoesdev
Copy link
Contributor

davedoesdev commented Feb 8, 2022

Version

v16.13.1

Platform

Linux david-Latitude-E6440 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

http2

What steps will reproduce the bug?

Run this program:

const { createServer, connect } = require('http2');
const assert = require('assert');

createServer().on('stream', function (stream) {
    stream.respond({
        ':status': 200,
        'Content-Type': 'application/octet-stream'
    });
    stream.on('end', () => {
        stream.end();
        stream.session.close();
        this.close();
    });
    stream.resume();
}).listen(7000, () => {
    connect('http://localhost:7000', function () {
        this.request({
            ':method': 'POST'
        }, {
            waitForTrailers: true
        }).on('response', function () {
            this.end('12345');
            this.on('error', err => assert.equal(err.message, 'write after end'));
            this.write('6');
        }).on('wantTrailers', function () {
            this.sendTrailers({});
        });
    });
});

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

Every time

What is the expected behavior?

Program should exit

What do you see instead?

Program doesn't exit because server stream doesn't get end event.

Additional information

If you remove the write after end (this.write('6')) then the program exits.
Something is stopping the wantTrailers event being emitted and so the client stream never ends.

Note, changing to waitForTrailers: false also makes it exit (server gets end event).

@davedoesdev
Copy link
Contributor Author

OK I guess this is expected behaviour due to 7a7ba82

@davedoesdev
Copy link
Contributor Author

davedoesdev commented Feb 8, 2022

Just not sure that an error which occurs after ending the stream should cause the stream not to end.

@VoltrexKeyva VoltrexKeyva added the http2 Issues or PRs related to the http2 subsystem. label Feb 9, 2022
@benjamingr
Copy link
Member

@ronag can you confirm this is expected?

@ronag
Copy link
Member

ronag commented Feb 16, 2022

This is expected behavior.

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

4 participants