Skip to content

Commit

Permalink
ref(#12): switch to an official version of cht-conf support session
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpascal committed Jun 20, 2024
1 parent 6f48e8b commit 594f62f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 40 deletions.
80 changes: 42 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"axios": "^1.5.1",
"axios-retry": "^4.0.0",
"bullmq": "^5.7.6",
"cht-conf": "github:medic/cht-conf#session-token-auth",
"cht-conf": "^3.23.0",
"csv": "^6.3.5",
"dotenv": "^16.3.1",
"fastify": "^4.27.0",
Expand Down
5 changes: 4 additions & 1 deletion src/worker/move-contact-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class MoveContactWorker {
private async executeCommand(command: string, args: string[]): Promise<void> {
return new Promise((resolve, reject) => {
const chtProcess = spawn(command, args);
let lastOutput = '';

const timeout = setTimeout(() => {
chtProcess.kill();
Expand All @@ -120,6 +121,7 @@ export class MoveContactWorker {

chtProcess.stdout.on('data', data => {
console.log(`cht-conf: ${data}`);
lastOutput = data.toString();
});

chtProcess.stderr.on('data', error => {
Expand All @@ -131,11 +133,12 @@ export class MoveContactWorker {
if (code === 0) {
resolve();
}
reject(new Error(`cht-conf exited with code ${code}`));
reject(new Error(`cht-conf exited with code ${code}. Last output: ${lastOutput}`));
});

chtProcess.on('error', error => {
clearTimeout(timeout);
console.log(error);
reject(error);
});
});
Expand Down

0 comments on commit 594f62f

Please sign in to comment.