Dynamic jobs not being cleared on application shutdown
Nosfistis opened this issue · comments
I'm submitting a...
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Any job created with SchedulerRegistry
is not being cleared on application shutdown.
Expected behavior
All jobs, both those declared with decorators, and those declared with the Dynamic API, should be cleared on shutdown.
Minimal reproduction of the problem with instructions
You can run the test added below:
https://github.com/Nosfistis/schedule/tree/bugfix/shutdown-cleanup
As a quickfix to pass the test, add this to orchestrator:
clearIntervals() {
this.schedulerRegistry.getIntervals().forEach(interval => this.schedulerRegistry.deleteInterval(interval));
}
What is the motivation / use case for changing the behavior?
This is an important issue since the application never really shuts down if closed with app.close()
, and the jobs keep running. It has been a major issue in my e2e tests, and took a while to find out.
I am not sure why both the orchestrator and the registry hold references to the current jobs. I feel like the orchestrator should delegate everything to the registry, and not hold any reference locally.
Clearing up on shutdown could easily be done by calling registry methods as well.
Environment
Nest version: 0.4.0
For Tooling issues:
- Node version: 14.8
- Platform: Windows
Others:
Would you like to create a PR for this issue?
PR open!