1+ import whyIsNodeRunning from 'why-is-node-running' // should be your first import
2+
13import { createWriteStream , openAsBlob } from 'node:fs' ;
24import { stat } from 'node:fs/promises' ;
35import { Writable } from 'node:stream' ;
@@ -553,12 +555,19 @@ export const handleArgs = (args: string[]) => {
553555 } ) ;
554556 try {
555557 log ( 'SILLY' , `Initialized client` ) ;
556-
557558 log ( 'DEBUG' , `About to TDF3 decrypt [${ argv . file } ]` ) ;
558559 const ct = await client . read ( await parseReadOptions ( argv ) ) ;
560+ log ( 'SILLY' , `acquired read stream` ) ;
559561 const destination = argv . output ? createWriteStream ( argv . output ) : process . stdout ;
560- await ct . pipeTo ( Writable . toWeb ( destination ) ) ;
562+ log ( 'SILLY' , `acquired destination stream` ) ;
563+ try {
564+ await ct . pipeTo ( Writable . toWeb ( destination ) ) ;
565+ } catch ( e ) {
566+ log ( 'ERROR' , `Failed to pipe to destination stream: ${ e } ` ) ;
567+ }
568+ log ( 'SILLY' , `piped to destination stream` ) ;
561569 const lastRequest = authProvider . requestLog [ authProvider . requestLog . length - 1 ] ;
570+ log ( 'SILLY' , `last request is ${ JSON . stringify ( lastRequest ) } ` ) ;
562571 let accessToken = null ;
563572 let dpopToken = null ;
564573 for ( const h of Object . keys ( lastRequest . headers ) ) {
@@ -580,6 +589,7 @@ export const handleArgs = (args: string[]) => {
580589 }
581590 console . assert ( accessToken , 'No access_token found' ) ;
582591 console . assert ( ! argv . dpop || dpopToken , 'DPoP requested but absent' ) ;
592+ setImmediate ( ( ) => whyIsNodeRunning ( ) )
583593 } finally {
584594 client . close ( ) ;
585595 }
0 commit comments