Adjust croner integration to 6.x. Add version in README.md.#168
Adjust croner integration to 6.x. Add version in README.md.#168Hexagon wants to merge 1 commit intokibertoad:mainfrom
Conversation
f9101bb to
56edbd5
Compare
|
Updated for croner@6.0.2 |
| this.task.execute() | ||
| } | ||
| } | ||
| async () => await this.task.execute() |
There was a problem hiding this comment.
@Hexagon Is it necessary to have an async function here? Wouldn't it suffice to do return Promise.resolve().then(() => this.task.execute())?
There was a problem hiding this comment.
@kibertoad Main reason for the async/await is that croner awaits the call internally, to make .isBusy() of the returned job work. Not too familiar with "raw" promises, guess you know better than me what should be used here 👀
() => return this.task.execute() might pass the promise further, allowing the croner await to work?
There was a problem hiding this comment.
since you are awaiting it anyway, doing so here makes little sense.
mixing async functions and callbacks can be error-prone, so I would avoid introducing async function without a good reason.
() => return this.task.execute() might pass the promise further, allowing the croner await to work?
if croner does not necessarily expect a fully formed promise there (e. g. does not attach .then or .catch handlers to it), that should be sufficient, as await will work with both synchronous and asynchronous tasks, yes
There was a problem hiding this comment.
Hmm, the overrun-test (allows preventing CronJob execution overrun with async tasks) only pass using async/await
There was a problem hiding this comment.
The overrun protection does not work, the function is triggered again after 4000ms even though it should be blocking for 5000ms (pattern */2 * * ..)
This is how croner is expected to handle it https://github.com/Hexagon/croner/blob/master/docs/EXAMPLES.md#overrun-protection
... and the overrun protection works by setting blocked = x before and after calling the function, and awaiting the function
https://github.com/Hexagon/croner/blob/9a66976992a571074c9f508e02f9746649dd5a67/src/croner.js#L421
There was a problem hiding this comment.
Looks like you are depending on it being a function then.
So I would suggest going the Promise.resolve route then
There was a problem hiding this comment.
I can't seem to get this test working, can you have a look?
There was a problem hiding this comment.
sure, I'll check it out tomorrow
|
I haven't forgotten about it, and looked into it in several different occassions, but I haven't figured out what exactly goes wrong there. Will give it another short in the nearby future |
|
@kibertoad any update? |
Fixes #167