-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Programmatically stop croner #26
Comments
Yeah, you can stop it from both "inside" and "outside". const job = Cron('xxx', (_job) => { /* option 1 */ _job.stop();});
// Option 2
job.stop(); Works? :) See internal test suite for examples of promise handling https://github.com/Hexagon/croner/blob/master/test/src/suite.cjs |
Thanks for the quick response! Yeah, I stopped all the jobs this way, but the process itself keeps running. If there are no running jobs, croner stops the process? It seems like there is a pending |
Hmm, croner does not fork processes or anything, it's basically a If croner causes this, it would be awesome if you could pinpoint the problem and paste some code here, so i can have a look at it :) |
I'll try, when I have time :) Thanks! |
Great, tried to reproduce it using different techniques, but this is the only one that finish the scheduled function, but keep node running "unexpectedly". const Cron = require("croner");
async function runsToInfinity() { setTimeout(runsToInfinity, 1000); }
const job = Cron('* * * * * *', async (self) => {
// No await
runsToInfinity();
// Option 1, will not stop execution
console.log('Yay, done!');
self.stop();
} );
// Option 2 (wait 2 seconds to make sure execution is started)
// ... will not stop execution either
setTimeout( () => {
console.log('Yay, done again!');
job.stop();
}, 2000); |
Closing this, since there are no steps to reproduce. Please reopen if you find and document a way to reproduce this |
Thanks for the library!
Is there any way to programmatically stop croner? My Jest tests hangs until I manually kill tests process
The text was updated successfully, but these errors were encountered: