-
Notifications
You must be signed in to change notification settings - Fork 2
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: set maximum job timeout #244
Conversation
Vercel deployment URL: https://token-metadata-70g6r2zg8-hirosystems.vercel.app 🚀 |
@@ -43,8 +43,13 @@ export abstract class Job { | |||
// what to do in each case. If we choose to retry, this queue entry will simply not be marked as | |||
// `processed = true` so it can be picked up by the queue at a later time. | |||
try { | |||
await this.handler(); | |||
status = DbJobStatus.done; | |||
const success = await resolveOrTimeout(this.handler(), ENV.JOB_QUEUE_TIMEOUT_MS); |
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.
When this times out and returns continues with success==false
, what happens to the underlying promise? It doesn't look like there's termination code?
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.
That part is supposed to be handled by the tookit here: https://github.com/hirosystems/api-toolkit/blob/develop/src/helpers/time.ts#L68
But let me know if you think I should add something extra like an abort controller, etc.
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.
Here's the scenario that seems like it could cause issues:
async function someTask() {
await sleep(10_000);
console.log('something happens because task was still going');
}
const success = await resolveOrTimeout(someTask(), 100);
console.log(`Task done, success: ${success}`);
In something like the above, you'd hit the task done
, then later on have a dangling side-effect triggered in the background
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
## [1.0.0-beta.5](v1.0.0-beta.4...v1.0.0-beta.5) (2024-08-26) ### Bug Fixes * set maximum job timeout ([#244](#244)) ([3444917](3444917))
🎉 This PR is included in version 1.0.0-beta.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
## [1.0.0](v0.7.0...v1.0.0) (2024-08-26) ### ⚠ BREAKING CHANGES * use chainhook to listen for chain events instead of a direct stacks api connection (#200) ### Features * convert data: image uris into image files and upload to cdn ([#245](#245)) ([903b0aa](903b0aa)) ### Bug Fixes * catch econnreset errors ([#247](#247)) ([51347d6](51347d6)) * set maximum job timeout ([#244](#244)) ([3444917](3444917)) * take only first page of gif images ([#241](#241)) ([334f8c5](334f8c5)) * use bignumber to handle FT supplies ([#239](#239)) ([053d622](053d622)) * use google cloud library for image uploads ([#238](#238)) ([c7f1b43](c7f1b43)) * use prometheus port configured in ENV ([c769d29](c769d29)) ### Code Refactoring * use chainhook to listen for chain events instead of a direct stacks api connection ([#200](#200)) ([2ddb2c7](2ddb2c7)), closes [#229](#229) [#232](#232) [#233](#233) [#234](#234) [#235](#235) [#236](#236)
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Sets and enforces a maximum execution time for individual jobs.
Fixes #243