Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mixing break #1386

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/six-baboons-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

fix: erroring job
14 changes: 5 additions & 9 deletions apps/worker/job-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ async function runIfNotAlreadyRunning(
try {
runningJobs.add(jobId);

console.time(jobId);
console.log(`Start job ${jobId}-start`);

await fn();
Expand All @@ -69,22 +68,18 @@ async function runIfNotAlreadyRunning(
await cronsMetricPublisher.publish(`${jobId}-done`);
await cronsDurationMetricPublisher.publish(`${jobId}-done`, durationSuccess);
}
console.log(`Successful job ${jobId}-done`);
console.log(`Successful job ${jobId}-done`, durationSuccess);
} catch (error: any) {
const durationError = moment.duration(moment().diff(startJobTime)).asSeconds();
if (process.env.AWS_ALERTS === 'true') {
await cronsMetricPublisher.publish(`${jobId}-error`);
await cronsDurationMetricPublisher.publish(`${jobId}-error`, durationError);
}
console.log(`Error job ${jobId}-error`, error.message || error);
const duration = moment.duration(moment().diff(startJobTime)).asSeconds();
console.log(`Error job ${jobId}-error`, duration, error.message || error);
next(error);
} finally {
try {
runningJobs.delete(jobId);
} catch (error: any) {
console.error(`Error deleting job ${jobId}`, error.message || error);
}
console.timeEnd(jobId);
runningJobs.delete(jobId);
res.sendStatus(200);
}
}
Expand Down Expand Up @@ -276,6 +271,7 @@ const setupJobHandlers = async (name: string, chainId: string, res: any, next: N
res,
next,
);
break;
case 'sync-sts-staking-snapshots':
await runIfNotAlreadyRunning(
name,
Expand Down
Loading