11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { Readable, addAbortSignal } = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const read = new Readable({ 91cb0ef41Sopenharmony_ci read() {} 101cb0ef41Sopenharmony_ci }); 111cb0ef41Sopenharmony_ci read.resume(); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci read.on('close', common.mustCall()); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci read.destroy(); 161cb0ef41Sopenharmony_ci assert.strictEqual(read.errored, null); 171cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci const read = new Readable({ 221cb0ef41Sopenharmony_ci read() {} 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci read.resume(); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci const expected = new Error('kaboom'); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall('no end event')); 291cb0ef41Sopenharmony_ci read.on('close', common.mustCall()); 301cb0ef41Sopenharmony_ci read.on('error', common.mustCall((err) => { 311cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci read.destroy(expected); 351cb0ef41Sopenharmony_ci assert.strictEqual(read.errored, expected); 361cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci{ 401cb0ef41Sopenharmony_ci const read = new Readable({ 411cb0ef41Sopenharmony_ci read() {} 421cb0ef41Sopenharmony_ci }); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci read._destroy = common.mustCall(function(err, cb) { 451cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 461cb0ef41Sopenharmony_ci cb(err); 471cb0ef41Sopenharmony_ci }); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci const expected = new Error('kaboom'); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall('no end event')); 521cb0ef41Sopenharmony_ci read.on('close', common.mustCall()); 531cb0ef41Sopenharmony_ci read.on('error', common.mustCall((err) => { 541cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 551cb0ef41Sopenharmony_ci })); 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci read.destroy(expected); 581cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 591cb0ef41Sopenharmony_ci} 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ci{ 621cb0ef41Sopenharmony_ci const read = new Readable({ 631cb0ef41Sopenharmony_ci read() {}, 641cb0ef41Sopenharmony_ci destroy: common.mustCall(function(err, cb) { 651cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 661cb0ef41Sopenharmony_ci cb(); 671cb0ef41Sopenharmony_ci }) 681cb0ef41Sopenharmony_ci }); 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci const expected = new Error('kaboom'); 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall('no end event')); 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci // Error is swallowed by the custom _destroy 751cb0ef41Sopenharmony_ci read.on('error', common.mustNotCall('no error event')); 761cb0ef41Sopenharmony_ci read.on('close', common.mustCall()); 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci read.destroy(expected); 791cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 801cb0ef41Sopenharmony_ci} 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci{ 831cb0ef41Sopenharmony_ci const read = new Readable({ 841cb0ef41Sopenharmony_ci read() {} 851cb0ef41Sopenharmony_ci }); 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci read._destroy = common.mustCall(function(err, cb) { 881cb0ef41Sopenharmony_ci assert.strictEqual(err, null); 891cb0ef41Sopenharmony_ci cb(); 901cb0ef41Sopenharmony_ci }); 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci read.destroy(); 931cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 941cb0ef41Sopenharmony_ci} 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci{ 971cb0ef41Sopenharmony_ci const read = new Readable({ 981cb0ef41Sopenharmony_ci read() {} 991cb0ef41Sopenharmony_ci }); 1001cb0ef41Sopenharmony_ci read.resume(); 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci read._destroy = common.mustCall(function(err, cb) { 1031cb0ef41Sopenharmony_ci assert.strictEqual(err, null); 1041cb0ef41Sopenharmony_ci process.nextTick(() => { 1051cb0ef41Sopenharmony_ci this.push(null); 1061cb0ef41Sopenharmony_ci cb(); 1071cb0ef41Sopenharmony_ci }); 1081cb0ef41Sopenharmony_ci }); 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ci const fail = common.mustNotCall('no end event'); 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci read.on('end', fail); 1131cb0ef41Sopenharmony_ci read.on('close', common.mustCall()); 1141cb0ef41Sopenharmony_ci 1151cb0ef41Sopenharmony_ci read.destroy(); 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci read.removeListener('end', fail); 1181cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall()); 1191cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 1201cb0ef41Sopenharmony_ci} 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ci{ 1231cb0ef41Sopenharmony_ci const read = new Readable({ 1241cb0ef41Sopenharmony_ci read() {} 1251cb0ef41Sopenharmony_ci }); 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci const expected = new Error('kaboom'); 1281cb0ef41Sopenharmony_ci 1291cb0ef41Sopenharmony_ci read._destroy = common.mustCall(function(err, cb) { 1301cb0ef41Sopenharmony_ci assert.strictEqual(err, null); 1311cb0ef41Sopenharmony_ci cb(expected); 1321cb0ef41Sopenharmony_ci }); 1331cb0ef41Sopenharmony_ci 1341cb0ef41Sopenharmony_ci let ticked = false; 1351cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall('no end event')); 1361cb0ef41Sopenharmony_ci read.on('error', common.mustCall((err) => { 1371cb0ef41Sopenharmony_ci assert.strictEqual(ticked, true); 1381cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errorEmitted, true); 1391cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errored, expected); 1401cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 1411cb0ef41Sopenharmony_ci })); 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ci read.destroy(); 1441cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errorEmitted, false); 1451cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errored, expected); 1461cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 1471cb0ef41Sopenharmony_ci ticked = true; 1481cb0ef41Sopenharmony_ci} 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci{ 1511cb0ef41Sopenharmony_ci const read = new Readable({ 1521cb0ef41Sopenharmony_ci read() {} 1531cb0ef41Sopenharmony_ci }); 1541cb0ef41Sopenharmony_ci read.resume(); 1551cb0ef41Sopenharmony_ci 1561cb0ef41Sopenharmony_ci read.destroyed = true; 1571cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ci // The internal destroy() mechanism should not be triggered 1601cb0ef41Sopenharmony_ci read.on('end', common.mustNotCall()); 1611cb0ef41Sopenharmony_ci read.destroy(); 1621cb0ef41Sopenharmony_ci} 1631cb0ef41Sopenharmony_ci 1641cb0ef41Sopenharmony_ci{ 1651cb0ef41Sopenharmony_ci function MyReadable() { 1661cb0ef41Sopenharmony_ci assert.strictEqual(this.destroyed, false); 1671cb0ef41Sopenharmony_ci this.destroyed = false; 1681cb0ef41Sopenharmony_ci Readable.call(this); 1691cb0ef41Sopenharmony_ci } 1701cb0ef41Sopenharmony_ci 1711cb0ef41Sopenharmony_ci Object.setPrototypeOf(MyReadable.prototype, Readable.prototype); 1721cb0ef41Sopenharmony_ci Object.setPrototypeOf(MyReadable, Readable); 1731cb0ef41Sopenharmony_ci 1741cb0ef41Sopenharmony_ci new MyReadable(); 1751cb0ef41Sopenharmony_ci} 1761cb0ef41Sopenharmony_ci 1771cb0ef41Sopenharmony_ci{ 1781cb0ef41Sopenharmony_ci // Destroy and destroy callback 1791cb0ef41Sopenharmony_ci const read = new Readable({ 1801cb0ef41Sopenharmony_ci read() {} 1811cb0ef41Sopenharmony_ci }); 1821cb0ef41Sopenharmony_ci read.resume(); 1831cb0ef41Sopenharmony_ci 1841cb0ef41Sopenharmony_ci const expected = new Error('kaboom'); 1851cb0ef41Sopenharmony_ci 1861cb0ef41Sopenharmony_ci let ticked = false; 1871cb0ef41Sopenharmony_ci read.on('close', common.mustCall(() => { 1881cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errorEmitted, true); 1891cb0ef41Sopenharmony_ci assert.strictEqual(ticked, true); 1901cb0ef41Sopenharmony_ci })); 1911cb0ef41Sopenharmony_ci read.on('error', common.mustCall((err) => { 1921cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 1931cb0ef41Sopenharmony_ci })); 1941cb0ef41Sopenharmony_ci 1951cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errored, null); 1961cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errorEmitted, false); 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci read.destroy(expected, common.mustCall(function(err) { 1991cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errored, expected); 2001cb0ef41Sopenharmony_ci assert.strictEqual(err, expected); 2011cb0ef41Sopenharmony_ci })); 2021cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errorEmitted, false); 2031cb0ef41Sopenharmony_ci assert.strictEqual(read._readableState.errored, expected); 2041cb0ef41Sopenharmony_ci ticked = true; 2051cb0ef41Sopenharmony_ci} 2061cb0ef41Sopenharmony_ci 2071cb0ef41Sopenharmony_ci{ 2081cb0ef41Sopenharmony_ci const readable = new Readable({ 2091cb0ef41Sopenharmony_ci destroy: common.mustCall(function(err, cb) { 2101cb0ef41Sopenharmony_ci process.nextTick(cb, new Error('kaboom 1')); 2111cb0ef41Sopenharmony_ci }), 2121cb0ef41Sopenharmony_ci read() {} 2131cb0ef41Sopenharmony_ci }); 2141cb0ef41Sopenharmony_ci 2151cb0ef41Sopenharmony_ci let ticked = false; 2161cb0ef41Sopenharmony_ci readable.on('close', common.mustCall(() => { 2171cb0ef41Sopenharmony_ci assert.strictEqual(ticked, true); 2181cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errorEmitted, true); 2191cb0ef41Sopenharmony_ci })); 2201cb0ef41Sopenharmony_ci readable.on('error', common.mustCall((err) => { 2211cb0ef41Sopenharmony_ci assert.strictEqual(ticked, true); 2221cb0ef41Sopenharmony_ci assert.strictEqual(err.message, 'kaboom 1'); 2231cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errorEmitted, true); 2241cb0ef41Sopenharmony_ci })); 2251cb0ef41Sopenharmony_ci 2261cb0ef41Sopenharmony_ci readable.destroy(); 2271cb0ef41Sopenharmony_ci assert.strictEqual(readable.destroyed, true); 2281cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errored, null); 2291cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errorEmitted, false); 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci // Test case where `readable.destroy()` is called again with an error before 2321cb0ef41Sopenharmony_ci // the `_destroy()` callback is called. 2331cb0ef41Sopenharmony_ci readable.destroy(new Error('kaboom 2')); 2341cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errorEmitted, false); 2351cb0ef41Sopenharmony_ci assert.strictEqual(readable._readableState.errored, null); 2361cb0ef41Sopenharmony_ci 2371cb0ef41Sopenharmony_ci ticked = true; 2381cb0ef41Sopenharmony_ci} 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci{ 2411cb0ef41Sopenharmony_ci const read = new Readable({ 2421cb0ef41Sopenharmony_ci read() {} 2431cb0ef41Sopenharmony_ci }); 2441cb0ef41Sopenharmony_ci 2451cb0ef41Sopenharmony_ci read.destroy(); 2461cb0ef41Sopenharmony_ci read.push('hi'); 2471cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 2481cb0ef41Sopenharmony_ci} 2491cb0ef41Sopenharmony_ci 2501cb0ef41Sopenharmony_ci{ 2511cb0ef41Sopenharmony_ci const read = new Readable({ 2521cb0ef41Sopenharmony_ci read: common.mustNotCall() 2531cb0ef41Sopenharmony_ci }); 2541cb0ef41Sopenharmony_ci read.destroy(); 2551cb0ef41Sopenharmony_ci assert.strictEqual(read.destroyed, true); 2561cb0ef41Sopenharmony_ci read.read(); 2571cb0ef41Sopenharmony_ci} 2581cb0ef41Sopenharmony_ci 2591cb0ef41Sopenharmony_ci{ 2601cb0ef41Sopenharmony_ci const read = new Readable({ 2611cb0ef41Sopenharmony_ci autoDestroy: false, 2621cb0ef41Sopenharmony_ci read() { 2631cb0ef41Sopenharmony_ci this.push(null); 2641cb0ef41Sopenharmony_ci this.push('asd'); 2651cb0ef41Sopenharmony_ci } 2661cb0ef41Sopenharmony_ci }); 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ci read.on('error', common.mustCall(() => { 2691cb0ef41Sopenharmony_ci assert(read._readableState.errored); 2701cb0ef41Sopenharmony_ci })); 2711cb0ef41Sopenharmony_ci read.resume(); 2721cb0ef41Sopenharmony_ci} 2731cb0ef41Sopenharmony_ci 2741cb0ef41Sopenharmony_ci{ 2751cb0ef41Sopenharmony_ci const controller = new AbortController(); 2761cb0ef41Sopenharmony_ci const read = addAbortSignal(controller.signal, new Readable({ 2771cb0ef41Sopenharmony_ci read() { 2781cb0ef41Sopenharmony_ci this.push('asd'); 2791cb0ef41Sopenharmony_ci }, 2801cb0ef41Sopenharmony_ci })); 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ci read.on('error', common.mustCall((e) => { 2831cb0ef41Sopenharmony_ci assert.strictEqual(e.name, 'AbortError'); 2841cb0ef41Sopenharmony_ci })); 2851cb0ef41Sopenharmony_ci controller.abort(); 2861cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 2871cb0ef41Sopenharmony_ci} 2881cb0ef41Sopenharmony_ci 2891cb0ef41Sopenharmony_ci{ 2901cb0ef41Sopenharmony_ci const controller = new AbortController(); 2911cb0ef41Sopenharmony_ci const read = new Readable({ 2921cb0ef41Sopenharmony_ci signal: controller.signal, 2931cb0ef41Sopenharmony_ci read() { 2941cb0ef41Sopenharmony_ci this.push('asd'); 2951cb0ef41Sopenharmony_ci }, 2961cb0ef41Sopenharmony_ci }); 2971cb0ef41Sopenharmony_ci 2981cb0ef41Sopenharmony_ci read.on('error', common.mustCall((e) => { 2991cb0ef41Sopenharmony_ci assert.strictEqual(e.name, 'AbortError'); 3001cb0ef41Sopenharmony_ci })); 3011cb0ef41Sopenharmony_ci controller.abort(); 3021cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3031cb0ef41Sopenharmony_ci} 3041cb0ef41Sopenharmony_ci 3051cb0ef41Sopenharmony_ci{ 3061cb0ef41Sopenharmony_ci const controller = new AbortController(); 3071cb0ef41Sopenharmony_ci const read = addAbortSignal(controller.signal, new Readable({ 3081cb0ef41Sopenharmony_ci objectMode: true, 3091cb0ef41Sopenharmony_ci read() { 3101cb0ef41Sopenharmony_ci return false; 3111cb0ef41Sopenharmony_ci } 3121cb0ef41Sopenharmony_ci })); 3131cb0ef41Sopenharmony_ci read.push('asd'); 3141cb0ef41Sopenharmony_ci 3151cb0ef41Sopenharmony_ci read.on('error', common.mustCall((e) => { 3161cb0ef41Sopenharmony_ci assert.strictEqual(e.name, 'AbortError'); 3171cb0ef41Sopenharmony_ci })); 3181cb0ef41Sopenharmony_ci assert.rejects((async () => { 3191cb0ef41Sopenharmony_ci // eslint-disable-next-line no-unused-vars, no-empty 3201cb0ef41Sopenharmony_ci for await (const chunk of read) { } 3211cb0ef41Sopenharmony_ci })(), /AbortError/); 3221cb0ef41Sopenharmony_ci setTimeout(() => controller.abort(), 0); 3231cb0ef41Sopenharmony_ci} 3241cb0ef41Sopenharmony_ci 3251cb0ef41Sopenharmony_ci{ 3261cb0ef41Sopenharmony_ci const read = new Readable({ 3271cb0ef41Sopenharmony_ci read() { 3281cb0ef41Sopenharmony_ci }, 3291cb0ef41Sopenharmony_ci }); 3301cb0ef41Sopenharmony_ci 3311cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3321cb0ef41Sopenharmony_ci read.on('error', common.mustCall((e) => { 3331cb0ef41Sopenharmony_ci read.push('asd'); 3341cb0ef41Sopenharmony_ci read.read(); 3351cb0ef41Sopenharmony_ci })); 3361cb0ef41Sopenharmony_ci read.on('close', common.mustCall((e) => { 3371cb0ef41Sopenharmony_ci read.push('asd'); 3381cb0ef41Sopenharmony_ci read.read(); 3391cb0ef41Sopenharmony_ci })); 3401cb0ef41Sopenharmony_ci read.destroy(new Error('asd')); 3411cb0ef41Sopenharmony_ci} 3421cb0ef41Sopenharmony_ci 3431cb0ef41Sopenharmony_ci{ 3441cb0ef41Sopenharmony_ci const read = new Readable({ 3451cb0ef41Sopenharmony_ci read() { 3461cb0ef41Sopenharmony_ci }, 3471cb0ef41Sopenharmony_ci }); 3481cb0ef41Sopenharmony_ci 3491cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3501cb0ef41Sopenharmony_ci read.on('close', common.mustCall((e) => { 3511cb0ef41Sopenharmony_ci read.push('asd'); 3521cb0ef41Sopenharmony_ci read.read(); 3531cb0ef41Sopenharmony_ci })); 3541cb0ef41Sopenharmony_ci read.destroy(); 3551cb0ef41Sopenharmony_ci} 3561cb0ef41Sopenharmony_ci 3571cb0ef41Sopenharmony_ci{ 3581cb0ef41Sopenharmony_ci const read = new Readable({ 3591cb0ef41Sopenharmony_ci read() { 3601cb0ef41Sopenharmony_ci }, 3611cb0ef41Sopenharmony_ci }); 3621cb0ef41Sopenharmony_ci 3631cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3641cb0ef41Sopenharmony_ci read.on('close', common.mustCall((e) => { 3651cb0ef41Sopenharmony_ci read.push('asd'); 3661cb0ef41Sopenharmony_ci read.unshift('asd'); 3671cb0ef41Sopenharmony_ci })); 3681cb0ef41Sopenharmony_ci read.destroy(); 3691cb0ef41Sopenharmony_ci} 3701cb0ef41Sopenharmony_ci 3711cb0ef41Sopenharmony_ci{ 3721cb0ef41Sopenharmony_ci const read = new Readable({ 3731cb0ef41Sopenharmony_ci read() { 3741cb0ef41Sopenharmony_ci }, 3751cb0ef41Sopenharmony_ci }); 3761cb0ef41Sopenharmony_ci 3771cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3781cb0ef41Sopenharmony_ci read.destroy(); 3791cb0ef41Sopenharmony_ci read.unshift('asd'); 3801cb0ef41Sopenharmony_ci} 3811cb0ef41Sopenharmony_ci 3821cb0ef41Sopenharmony_ci{ 3831cb0ef41Sopenharmony_ci const read = new Readable({ 3841cb0ef41Sopenharmony_ci read() { 3851cb0ef41Sopenharmony_ci }, 3861cb0ef41Sopenharmony_ci }); 3871cb0ef41Sopenharmony_ci 3881cb0ef41Sopenharmony_ci read.resume(); 3891cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 3901cb0ef41Sopenharmony_ci read.on('close', common.mustCall((e) => { 3911cb0ef41Sopenharmony_ci read.push('asd'); 3921cb0ef41Sopenharmony_ci })); 3931cb0ef41Sopenharmony_ci read.destroy(); 3941cb0ef41Sopenharmony_ci} 3951cb0ef41Sopenharmony_ci 3961cb0ef41Sopenharmony_ci{ 3971cb0ef41Sopenharmony_ci const read = new Readable({ 3981cb0ef41Sopenharmony_ci read() { 3991cb0ef41Sopenharmony_ci }, 4001cb0ef41Sopenharmony_ci }); 4011cb0ef41Sopenharmony_ci 4021cb0ef41Sopenharmony_ci read.on('data', common.mustNotCall()); 4031cb0ef41Sopenharmony_ci read.destroy(); 4041cb0ef41Sopenharmony_ci read.push('asd'); 4051cb0ef41Sopenharmony_ci} 406