File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -252,15 +252,20 @@ const { Blob } = require('buffer');
252252
253253// Ensure that given readable stream that throws an error it calls destroy
254254{
255- const myErrorMessage = 'error!' ;
256- const duplex = Duplex . from ( Readable ( {
257- read ( ) {
258- throw new Error ( myErrorMessage ) ;
259- }
260- } ) ) ;
261- duplex . on ( 'error' , common . mustCall ( ( msg ) => {
262- assert . strictEqual ( msg . message , myErrorMessage ) ;
263- } ) ) ;
255+ // As throwing exceptions on readable streams works only for Node v17+
256+ // Ignoring this test on older versions
257+ const isv16Higher = parseInt ( process . versions . node . match ( / \d { 2 } / ) ) > 16 ;
258+ if ( isv16Higher ) {
259+ const myErrorMessage = 'error!' ;
260+ const duplex = Duplex . from ( Readable ( {
261+ read ( ) {
262+ throw new Error ( myErrorMessage ) ;
263+ }
264+ } ) ) ;
265+ duplex . on ( 'error' , common . mustCall ( ( msg ) => {
266+ assert . strictEqual ( msg . message , myErrorMessage ) ;
267+ } ) ) ;
268+ }
264269}
265270
266271// Ensure that given writable stream that throws an error it calls destroy
You can’t perform that action at this time.
0 commit comments