Title: feat(webapp,database): opt-in per-client Prisma driver adapters by ericallam · Pull Request #4539 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: feat(webapp,database): opt-in per-client Prisma driver adapters by ericallam · Pull Request #4539 · triggerdotdev/trigger.dev
X Title: feat(webapp,database): opt-in per-client Prisma driver adapters by ericallam · Pull Request #4539 · triggerdotdev/trigger.dev
Description: What Adds an opt-in path to run each Prisma client through @prisma/adapter-pg (the node-postgres driver) instead of the built-in engine driver, controlled by a per-client env var, all off by default: env var client CONTROL_PLANE_DATABASE_WRITER_DRIVER_ADAPTER control-plane writer CONTROL_PLANE_DATABASE_REPLICA_DRIVER_ADAPTER control-plane replica RUN_OPS_DATABASE_WRITER_DRIVER_ADAPTER new run-ops writer RUN_OPS_DATABASE_REPLICA_DRIVER_ADAPTER new run-ops replica RUN_OPS_LEGACY_DATABASE_WRITER_DRIVER_ADAPTER legacy run-ops writer RUN_OPS_LEGACY_DATABASE_REPLICA_DRIVER_ADAPTER legacy run-ops replica With every flag unset the construction path is byte-identical to today (datasources URL + Rust engine), so this is inert until a flag is turned on. Per-client granularity allows enabling the adapter only where it's wanted. How Enables the driverAdapters preview feature on both schemas (@trigger.dev/database and @internal/run-ops-database). This keeps the Rust query engine — it does NOT add queryCompiler — so query behavior, result types, and engine tracing spans are unchanged. A shared buildDriverAdapterPool builds each client's pg.Pool with an explicit max, a bounded connectionTimeoutMillis (the node-postgres pool otherwise waits unbounded on acquire), and an onPoolError handler (an unhandled idle-connection error would otherwise crash the process). Threaded through all four client builders via a useDriverAdapter flag. Adds @prisma/adapter-pg + @types/pg to the webapp; pg is already pinned at 8.15.6 (adapter-pg 6.x requires pg < 8.17). Connect-failure handling (the important correctness/security bit) Under the adapter an unreachable DB no longer surfaces as PrismaClientInitializationError / P1001; it becomes a P2010 "Database not reachable: " (or a raw ECONNREFUSED/ENOTFOUND-class error). Two handlers are updated so a client on the adapter behaves like today: isInfrastructureError now recognizes those shapes (P2010 with a connectivity message, and raw connectivity errno codes). Without this, the DB hostname would leak into API-client-facing errors and the failure would go unlogged. Security-relevant. isPrismaRetriableError treats the adapter's pool-acquire timeout ("timeout exceeded when trying to connect") as retriable, preserving the P2024 retry behavior the adapter otherwise drops. Evidence Validated on an isolated stack that mirrors the production DB topology (chained PgBouncers in front of writer + reader): Behavioral parity: raw-query results and Prisma error codes/meta are byte-identical between the engine driver and the adapter across the queried shapes (unique-constraint meta.target, record-not-found, transaction-timeout, serialization-failure, etc.). Feature matrix: a full 380-project queue-ay pass shows no adapter-caused regressions — pass/fail parity between adapter-off and adapter-on, with the residual failures being pre-existing known-failures/flakes common to both. Rollout / rollback All flags default off; enable per client via env var, roll back by unsetting and redeploying (no data migration). Recommended first target is a single writer; enable one client at a time. Follow-ups (not in this PR) $metrics-based pool observability is removed under the adapter (the Prometheus route + db.pool.connections.* instruments); the metrics replacement (via pg.Pool counters) lands in a separate PR. Note for operators: on the adapter path, interactive-transaction maxWait does not bound pool acquisition — connectionTimeoutMillis does. Note on connection-string parameters The adapter pool is built from the base DSN, so Prisma-specific DSN parameters that node-postgres does not understand are not honored when a client is on the adapter: Prisma TLS spellings (sslaccept, sslcert, etc.) — node-postgres uses sslmode/ssl instead. Our production DSNs do not use these Prisma-specific TLS params, but any deployment whose DSN relies on them must be checked before enabling a flag. pgbouncer=true and statement_cache_size — effectively moot under the adapter, which uses no persistent named prepared statements. connection_limit, pool_timeout, and schema are handled explicitly (passed as max/connectionTimeoutMillis and PrismaPg's {schema} option). refs TRI-13039
Open Graph Description: What Adds an opt-in path to run each Prisma client through @prisma/adapter-pg (the node-postgres driver) instead of the built-in engine driver, controlled by a per-client env var, all off by defaul...
X Description: What Adds an opt-in path to run each Prisma client through @prisma/adapter-pg (the node-postgres driver) instead of the built-in engine driver, controlled by a per-client env var, all off by defaul...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4539
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:879fb25a-afd5-af88-57ef-3f4bb3ca632c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BD70:3AAE13:310757C:45ACD91:6AFAF178 |
| html-safe-nonce | 5624100e843678855e25a03b4aac133deb80fed5bfb69dfbd076c8ff8acb99c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDcwOjNBQUUxMzozMTA3NTdDOjQ1QUNEOTE6NkFGQUYxNzgiLCJ2aXNpdG9yX2lkIjoiNDAxMTk1MjIxMDIzNjMzODU1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b6064acce67a6b684a2e8700d09491ce74c1bce7e64890908a08a64559e72782 |
| hovercard-subject-tag | pull_request:4234723290 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4539/files |
| twitter:image | https://avatars.githubusercontent.com/u/534?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/534?s=400&v=4 |
| og:image:alt | What Adds an opt-in path to run each Prisma client through @prisma/adapter-pg (the node-postgres driver) instead of the built-in engine driver, controlled by a per-client env var, all off by defaul... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a85e96a83bed7871993e6b1ffda24105928eee17 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width