1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const stream = require('stream'); 6 7let pushes = 0; 8const total = 65500 + 40 * 1024; 9const rs = new stream.Readable({ 10 read: common.mustCall(function() { 11 if (pushes++ === 10) { 12 this.push(null); 13 return; 14 } 15 16 const length = this._readableState.length; 17 18 // We are at most doing two full runs of _reads 19 // before stopping, because Readable is greedy 20 // to keep its buffer full 21 assert(length <= total); 22 23 this.push(Buffer.alloc(65500)); 24 for (let i = 0; i < 40; i++) { 25 this.push(Buffer.alloc(1024)); 26 } 27 28 // We will be over highWaterMark at this point 29 // but a new call to _read is scheduled anyway. 30 }, 11) 31}); 32 33const ws = stream.Writable({ 34 write: common.mustCall(function(data, enc, cb) { 35 setImmediate(cb); 36 }, 41 * 10) 37}); 38 39rs.pipe(ws); 40