Skip to content

http2 client stops sending after stream has reached 16KiB #16578

Closed
@grantila

Description

@grantila
  • Version: 8.8.0
  • Platform: macOS High Sierra
  • Subsystem: http2

When piping a readable stream to an http2 request, it sends up to 16KiB of data, then sends no more. This can be reproduced by:

The following test server will write a file when anyone connects and sends data, using readable.pipe(writable). Usage: node server.js /tmp/foo to write /tmp/foo

const http2 = require('http2');
const fs = require('fs');

const server = http2.createServer();

const filename = process.argv[2];

server.on('stream', (stream, headers) => {
	console.log(headers);
	stream.pipe(fs.createWriteStream(filename));

	setTimeout(() => {
		stream.respond({
			'content-type': 'text/plain',
			':status': 200
		});
		stream.end("1 second has elapsed");
	}, 1000);
});

const port = 54321;
server.listen(port, err => {
	console.log('started server on port' + port);
});

The following test program reads a file and connects to an http2 server and streams the file content, also using readable.pipe(writable). Usage node client.js file-to-read.

This will succeed (small file): node client.js /etc/hosts
This will fail (large file): node client.js /usr/bin/ssh

const http2 = require('http2');
const {createReadStream} = require('fs');

const session = http2.connect("http://localhost:54321");
const req = session.request({
	':path': '/',
	':method': 'POST',
}, {
	endStream: false,
});

const filename = process.argv[process.argv.length-1];
createReadStream(filename).pipe(req);
req.pipe(process.stdout);
  • Expected behaviour: Stream handling should just work with the rest of Node.

#16213 might be related

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.http2Issues or 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