Skip to content

Commit

Permalink
fix: close db connections after running jobs from command line. (#9994)
Browse files Browse the repository at this point in the history
### What?

Exit process after `payload jobs:run` without cron is executed

### Why?

I would expect the `payload jobs:run` command to exit normally after
execution. With mongodb this is not the case as database connections are
open so the node process itself will not exit.

### How?

Execute `payload.db.destroy` to close all db connections after queue is
execution is done.

Fixes: #9851
  • Loading branch information
andershermansen authored Dec 30, 2024
1 parent 8671e85 commit eb69885
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/payload/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ export const bin = async () => {

return
} else {
return await payload.jobs.run({
await payload.jobs.run({
limit,
queue,
})

await payload.db.destroy() // close database connections after running jobs so process can exit cleanly

return
}
}

Expand Down

0 comments on commit eb69885

Please sign in to comment.