Closed tiberioalunni closed 3 months ago
I'm facing a problem calling pulse.stop(), here an examle:
pulse.stop().then(() => { console.log('Pulse stopped'); });
The problem is that in case of success of this._collection.updateMany resolve() is not called. Another problem that may exists is that in case of fail of this._collection.updateMany both reject(error) and resolve() are called.
See https://github.com/pulsecron/pulse/blob/v1.1.9/src/pulse/stop.ts
const _unlockJobs = async (): Promise<void> => { return new Promise((resolve, reject) => { debug('Pulse._unlockJobs()'); const jobIds = this._lockedJobs.map((job) => job.attrs._id); if (jobIds.length === 0) { debug('no jobs to unlock'); resolve(); } debug('about to unlock jobs with ids: %O', jobIds); this._collection.updateMany({ _id: { $in: jobIds } }, { $set: { lockedAt: null } }).catch((error) => { if (error) { reject(error); } this._lockedJobs = []; resolve(); }); }); };
I'm not sure 100% if the following solution is the best one, but I think it will work
this._collection.updateMany({ _id: { $in: jobIds } }, { $set: { lockedAt: null } }) .then() { this._lockedJobs = []; resolve(); } .catch((error) => { reject(error); });
Thank you for the issue! I will solve these and give you an answer as soon as possible.
@tiberioalunni This was fixed in v1.1.10 🚀
Nice! Thank you!
I'm facing a problem calling pulse.stop(), here an examle:
The problem is that in case of success of this._collection.updateMany resolve() is not called. Another problem that may exists is that in case of fail of this._collection.updateMany both reject(error) and resolve() are called.
See https://github.com/pulsecron/pulse/blob/v1.1.9/src/pulse/stop.ts
I'm not sure 100% if the following solution is the best one, but I think it will work