-
-
Couldn't load subscription status.
- Fork 869
Understanding postgres.js connection management in Trigger.dev v3 #2218
Unanswered
leedia-tech
asked this question in
Q&A
-
I'm using postgres.js and noticed your Drizzle example creates the db instance outside the task.
I'm wondering:
-
Task isolation: Do tasks run in separate workers/processes, or share the same Node process?
-
Connection lifecycle: If I create a postgres instance outside the task:
const sql = postgres(process.env.DATABASE_URL!) export const myTask = task({ id: "my-task", run: async (payload) => { return sql`SELECT * FROM users` } })
Is this instance shared across all executions, or does each worker get its own?
-
Connection cleanup: postgres.js requires
sql.end()to properly close connections. Should I handle this cleanup or does the worker lifecycle manage it?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment