-
Notifications
You must be signed in to change notification settings - Fork 15
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
batchRoute: Better handle job cancellation and deletion #1092
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,14 @@ function newProgressEmitter(task: ExecutableJob<JobDataType>) { | |
}); | ||
eventEmitter.on('checkpoint', (checkpoint: number) => { | ||
console.log('Task received checkpoint ', checkpoint); | ||
task.attributes.internal_data.checkpoint = checkpoint; | ||
task.save(); | ||
// Refresh the task before saving the checkpoint | ||
task.refresh() | ||
.then(() => { | ||
// Add checkpoint, then save the task | ||
task.attributes.internal_data.checkpoint = checkpoint; | ||
task.save().catch(() => console.error('Error saving task after checkpoint')); | ||
}) | ||
.catch(() => console.error('Error refreshing task before saving checkpoint')); // This will catch deleted jobs | ||
}); | ||
return eventEmitter; | ||
} | ||
|
@@ -65,7 +71,7 @@ const getTaskCancelledFct = (task: ExecutableJob<JobDataType>) => { | |
clearInterval(intervalObj); | ||
} | ||
}) | ||
.catch(() => (refreshError = true)); | ||
.catch(() => (refreshError = true)); // This will catch deleted jobs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking, you added the same comment as before without changing the code. This is accurate and not just a bad copy/paste ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's accurate, it adds an explanation of which kind of use case would be caught here. |
||
}, 5000); | ||
return () => refreshError || task.status === 'cancelled'; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an issue to track this? That seems important to get an answer to that