I noticed that pg-boss was causing my tests to hang (after it was fixed in 6.1.0). When I inspected further, I realized that when a job fails, the job expiration timer is not cleared. This causes long running (15m default) timers to pile up in memory. With a huge number of failed jobs, this could crash the application. Not to mention it causes tests to hang for 15m at least if you are testing failure cases.
I noticed that pg-boss was causing my tests to hang (after it was fixed in 6.1.0). When I inspected further, I realized that when a job fails, the job expiration timer is not cleared. This causes long running (15m default) timers to pile up in memory. With a huge number of failed jobs, this could crash the application. Not to mention it causes tests to hang for 15m at least if you are testing failure cases.
These lines appear to be causing the issue: https://github.com/timgit/pg-boss/blob/265d034243c6f2c9a536ecb417f0c7598d964d2e/src/manager.js#L174-L178
As you can see:
I would suggest changing the lines to:
Here is the script I used, if you want to see for yourself. https://github.com/aravindanve/pg-boss-shutdown-test/blob/main/index.js