- 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
consthttp2=require('http2');constfs=require('fs');constserver=http2.createServer();constfilename=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);});constport=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). Usagenode 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
consthttp2=require('http2');const{createReadStream}=require('fs');constsession=http2.connect("http://localhost:54321");constreq=session.request({':path': '/',':method': 'POST',},{endStream: false,});constfilename=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
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/footo write/tmp/fooThe following test program reads a file and connects to an http2 server and streams the file content, also using
readable.pipe(writable). Usagenode client.js file-to-read.This will succeed (small file):
node client.js /etc/hostsThis will fail (large file):
node client.js /usr/bin/ssh#16213 might be related