Skip to content

Commit eb69885

Browse files
fix: close db connections after running jobs from command line. (#9994)
### 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
1 parent 8671e85 commit eb69885

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/payload/src/bin/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ export const bin = async () => {
102102

103103
return
104104
} else {
105-
return await payload.jobs.run({
105+
await payload.jobs.run({
106106
limit,
107107
queue,
108108
})
109+
110+
await payload.db.destroy() // close database connections after running jobs so process can exit cleanly
111+
112+
return
109113
}
110114
}
111115

0 commit comments

Comments
 (0)