11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst stream = require('stream'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_cilet pushes = 0; 81cb0ef41Sopenharmony_ciconst total = 65500 + 40 * 1024; 91cb0ef41Sopenharmony_ciconst rs = new stream.Readable({ 101cb0ef41Sopenharmony_ci read: common.mustCall(function() { 111cb0ef41Sopenharmony_ci if (pushes++ === 10) { 121cb0ef41Sopenharmony_ci this.push(null); 131cb0ef41Sopenharmony_ci return; 141cb0ef41Sopenharmony_ci } 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci const length = this._readableState.length; 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci // We are at most doing two full runs of _reads 191cb0ef41Sopenharmony_ci // before stopping, because Readable is greedy 201cb0ef41Sopenharmony_ci // to keep its buffer full 211cb0ef41Sopenharmony_ci assert(length <= total); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci this.push(Buffer.alloc(65500)); 241cb0ef41Sopenharmony_ci for (let i = 0; i < 40; i++) { 251cb0ef41Sopenharmony_ci this.push(Buffer.alloc(1024)); 261cb0ef41Sopenharmony_ci } 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci // We will be over highWaterMark at this point 291cb0ef41Sopenharmony_ci // but a new call to _read is scheduled anyway. 301cb0ef41Sopenharmony_ci }, 11) 311cb0ef41Sopenharmony_ci}); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ciconst ws = stream.Writable({ 341cb0ef41Sopenharmony_ci write: common.mustCall(function(data, enc, cb) { 351cb0ef41Sopenharmony_ci setImmediate(cb); 361cb0ef41Sopenharmony_ci }, 41 * 10) 371cb0ef41Sopenharmony_ci}); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_cirs.pipe(ws); 40