Skip to content

Commit cb39951

Browse files
debugging
1 parent 2670111 commit cb39951

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

cli/package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"prettier": "^3.3.3",
4646
"sinon": "^19.0.2",
4747
"ts-node": "^10.9.2",
48-
"typescript": "^5.1.6"
48+
"typescript": "^5.1.6",
49+
"why-is-node-running": "^3.2.1"
4950
},
5051
"dependencies": {
5152
"@opentdf/sdk": "file:../lib/opentdf-sdk-0.2.0.tgz",

cli/src/cli.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import whyIsNodeRunning from 'why-is-node-running' // should be your first import
2+
13
import { createWriteStream, openAsBlob } from 'node:fs';
24
import { stat } from 'node:fs/promises';
35
import { 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

Comments
 (0)