@@ -293,16 +293,26 @@ describe("streams", () => {
293293
294294 // Add meta event handler to verify column metadata
295295 data . on ( "meta" , m => {
296- expect ( m ) . toEqual ( [
297- { name : "id" , type : "int" } ,
298- { name : "username" , type : "text" } ,
299- { name : "email" , type : "text" } ,
300- { name : "status" , type : "boolean" } ,
301- { name : "big_number" , type : "long" } ,
302- { name : "created_date" , type : "date" } ,
303- { name : "score" , type : "double" } ,
304- { name : "description" , type : "text" }
305- ] ) ;
296+ try {
297+ expect ( m ) . toEqual ( [
298+ { name : "id" , type : "int" } ,
299+ { name : "username" , type : "text" } ,
300+ { name : "email" , type : "text" } ,
301+ { name : "status" , type : "boolean" } ,
302+ { name : "big_number" , type : "long" } ,
303+ { name : "created_date" , type : "date" } ,
304+ { name : "score" , type : "double" } ,
305+ { name : "description" , type : "text" }
306+ ] ) ;
307+ } catch ( err ) {
308+ // Re-emit error so test fails properly
309+ data . destroy ( err as Error ) ;
310+ }
311+ } ) ;
312+
313+ // Add error handler to ensure any stream errors are caught
314+ data . on ( "error" , err => {
315+ throw err ;
306316 } ) ;
307317
308318 // Buffer pool configuration
@@ -398,15 +408,20 @@ describe("streams", () => {
398408 const outputStream = new stream . Transform ( {
399409 highWaterMark : 1 ,
400410 transform ( chunk , encoding , callback ) {
401- processedChunks ++ ;
402-
403- // Simulate occasional slow processing with minimal delays
404- if ( processedChunks % 1000 === 0 ) {
405- setTimeout ( ( ) => {
411+ try {
412+ processedChunks ++ ;
413+
414+ // Simulate occasional slow processing with minimal delays
415+ if ( processedChunks % 1000 === 0 ) {
416+ // Use setImmediate instead of setTimeout to avoid potential timing issues
417+ setImmediate ( ( ) => {
418+ callback ( ) ;
419+ } ) ;
420+ } else {
406421 callback ( ) ;
407- } , 1 ) ; // 1ms delay
408- } else {
409- callback ( ) ;
422+ }
423+ } catch ( err ) {
424+ callback ( err as Error ) ;
410425 }
411426 }
412427 } ) ;
0 commit comments