1
+ import whyIsNodeRunning from 'why-is-node-running' // should be your first import
2
+
1
3
import { createWriteStream , openAsBlob } from 'node:fs' ;
2
4
import { stat } from 'node:fs/promises' ;
3
5
import { Writable } from 'node:stream' ;
@@ -553,12 +555,19 @@ export const handleArgs = (args: string[]) => {
553
555
} ) ;
554
556
try {
555
557
log ( 'SILLY' , `Initialized client` ) ;
556
-
557
558
log ( 'DEBUG' , `About to TDF3 decrypt [${ argv . file } ]` ) ;
558
559
const ct = await client . read ( await parseReadOptions ( argv ) ) ;
560
+ log ( 'SILLY' , `acquired read stream` ) ;
559
561
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` ) ;
561
569
const lastRequest = authProvider . requestLog [ authProvider . requestLog . length - 1 ] ;
570
+ log ( 'SILLY' , `last request is ${ JSON . stringify ( lastRequest ) } ` ) ;
562
571
let accessToken = null ;
563
572
let dpopToken = null ;
564
573
for ( const h of Object . keys ( lastRequest . headers ) ) {
@@ -580,6 +589,7 @@ export const handleArgs = (args: string[]) => {
580
589
}
581
590
console . assert ( accessToken , 'No access_token found' ) ;
582
591
console . assert ( ! argv . dpop || dpopToken , 'DPoP requested but absent' ) ;
592
+ setImmediate ( ( ) => whyIsNodeRunning ( ) )
583
593
} finally {
584
594
client . close ( ) ;
585
595
}
0 commit comments