Skip to content

Commit 123cba1

Browse files
CopilotAnmol1696
andcommitted
Improve error logging with stack traces across job workers and scheduler
Co-authored-by: Anmol1696 <10805402+Anmol1696@users.noreply.github.com>
1 parent da3a3c7 commit 123cba1

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

jobs/job-scheduler/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ export default class Scheduler {
192192
release: () => void
193193
) => {
194194
if (err) {
195-
log.error('Error connecting with notify listener');
195+
log.error('Error connecting with notify listener', err);
196+
if (err.stack) {
197+
log.debug(err.stack);
198+
}
196199
// Try again in 5 seconds
197200
// should this really be done in the node process?
198201
setTimeout(this.listen, 5000);
@@ -207,7 +210,10 @@ export default class Scheduler {
207210
});
208211
client.query('LISTEN "scheduled_jobs:insert"');
209212
client.on('error', (e: unknown) => {
210-
log.error('Error with database notify listener');
213+
log.error('Error with database notify listener', e);
214+
if (e instanceof Error && e.stack) {
215+
log.debug(e.stack);
216+
}
211217
release();
212218
this.listen();
213219
});

jobs/knative-job-worker/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ export default class Worker {
176176
release: () => void
177177
) => {
178178
if (err) {
179-
log.error('Error connecting with notify listener');
179+
log.error('Error connecting with notify listener', err);
180+
if (err.stack) {
181+
log.debug(err.stack);
182+
}
180183
// Try again in 5 seconds
181184
// should this really be done in the node process?
182185
setTimeout(this.listen, 5000);
@@ -190,7 +193,10 @@ export default class Worker {
190193
});
191194
client.query('LISTEN "jobs:insert"');
192195
client.on('error', (e: unknown) => {
193-
log.error('Error with database notify listener');
196+
log.error('Error with database notify listener', e);
197+
if (e instanceof Error && e.stack) {
198+
log.debug(e.stack);
199+
}
194200
release();
195201
this.listen();
196202
});

0 commit comments

Comments
 (0)