-
-
Notifications
You must be signed in to change notification settings - Fork 891
Prisma 6.14.0 upgrade #2444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prisma 6.14.0 upgrade #2444
Conversation
matt-aitken
commented
Aug 27, 2025
- Upgrade Prisma and instrumentation to 6.14.0
- Move generated artifacts to ./generated folder and update types to fix
- Added ClickHouse restart handling
|
WalkthroughPrisma is upgraded to 6.14.0 across packages; client generation now outputs to internal-packages/database/generated/prisma and tracing preview feature removed. decimal.js was added and exported for Decimal. Database exports now re-export from the generated client and transaction types were adjusted (local TransactionIsolationLevel, PrismaClientKnownRequestError usage). Webapp: tighter type-only Prisma imports, added query-performance monitoring with VERY_SLOW_QUERY_THRESHOLD_MS env, and a Uint8Array-based decompression change. Dockerfiles and compose updated for Prisma tooling and clickhouse restart; .gitignore/.dockerignore ignore generated/prisma. Cursor rules globs for services/presenters updated. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
.cursor/rules/webapp.mdc (1)
34-41: Fix globs and remove duplicates; current patterns won’t match files.Use recursive globs and dedupe the bullets.
-- All the "services" that are found in app/v3/services/*_/_.server.ts +- All the "services" that are found in app/v3/services/**/*.server.ts @@ -- We use "presenters" to move more complex loader code into a class, and you can find those are app/v3/presenters/*_/_.server.ts +- We use "presenters" to move more complex loader code into a class, and you can find those at app/v3/presenters/**/*.server.ts @@ -- All the "services" that are found in app/v3/services/*_/_.server.ts -- The code for the TaskEvent data, which is the otel data sent from tasks to our servers, is in both the [eventRepository.server.ts](mdc:apps/webapp/app/v3/eventRepository.server.ts) and also the [otlpExporter.server.ts](mdc:apps/webapp/app/v3/otlpExporter.server.ts). The otel endpoints which are hit from production and development otel exporters is [otel.v1.logs.ts](mdc:apps/webapp/app/routes/otel.v1.logs.ts) and [otel.v1.traces.ts](mdc:apps/webapp/app/routes/otel.v1.traces.ts) -- We use "presenters" to move more complex loader code into a class, and you can find those are app/v3/presenters/*_/_.server.ts +apps/webapp/app/db.server.ts (3)
108-116: Webapp must use env.server.ts for DATABASE_URL (guideline violation)Replace direct process.env access with env.DATABASE_URL.
Apply:
- const { DATABASE_URL } = process.env; - invariant(typeof DATABASE_URL === "string", "DATABASE_URL env var not set"); + invariant(typeof env.DATABASE_URL === "string", "DATABASE_URL env var not set"); - const databaseUrl = extendQueryParams(DATABASE_URL, { + const databaseUrl = extendQueryParams(env.DATABASE_URL, {
371-372: Use Prisma.raw for dynamic schema identifiers (Prisma.sql usage is incorrect here)Prisma.sql expects a template tag; for identifiers use Prisma.raw.
Apply:
-export const sqlDatabaseSchema = Prisma.sql([`${DATABASE_SCHEMA}`]); +export const sqlDatabaseSchema = Prisma.raw(DATABASE_SCHEMA);
140-156: Add missing environment variables and refactor direct process.env accessThe new Prisma logging flags aren’t defined in
apps/webapp/app/env.server.ts, so we need to:
- Define
PRISMA_LOG_TO_STDOUTandVERBOSE_PRISMA_LOGSinenv.server.ts.- Replace all direct
process.env.*usages inapps/webapp/app/db.server.tswithenv.*.• File: apps/webapp/app/env.server.ts
import { z } from "zod" // …existing exports… export const PRISMA_LOG_TO_STDOUT = z .string() .optional() .transform((val) => val === "1") export const VERBOSE_PRISMA_LOGS = z .string() .optional() .transform((val) => val === "1") export const env = { // …other vars PRISMA_LOG_TO_STDOUT, VERBOSE_PRISMA_LOGS, }• File: apps/webapp/app/db.server.ts
Replace each block like:- ...((process.env.PRISMA_LOG_TO_STDOUT === "1" + ...((env.PRISMA_LOG_TO_STDOUT ? [and
- ...((process.env.VERBOSE_PRISMA_LOGS === "1" + ...((env.VERBOSE_PRISMA_LOGS ? [in the main client (lines 140–156, 157–169) and replica client (lines 252–267, 269–281).
This ensures all environment variables are accessed through the centralized
envAPI as per webapp conventions.
🧹 Nitpick comments (10)
docker/docker-compose.yml (1)
78-82: ClickHouse restart policy added — good resilience; consider pinning image tag
restart: alwaysis a sensible addition for CH stability. As a small hardening, pinimageto a version (or digest) to avoid surprise upgrades.- image: bitnami/clickhouse:latest + image: bitnami/clickhouse:24.8apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.ts (1)
85-87: Avoid double Buffer allocation when base64-decodingMinor simplification and fewer copies.
-function decompressContent(compressedBuffer: Uint8Array): string { - // Convert Uint8Array to Buffer and decode base64 in one step - const decodedBuffer = Buffer.from(Buffer.from(compressedBuffer).toString("utf-8"), "base64"); +function decompressContent(compressedBuffer: Uint8Array): string { + // Convert bytes of the base64 string → actual bytes + const base64 = Buffer.from(compressedBuffer).toString("utf8"); + const decodedBuffer = Buffer.from(base64, "base64");docker/Dockerfile (2)
41-41: Pin Prisma version via ARG and keep CLI/client in lockstep.Parameterize the Prisma version and use it here to avoid drift with @prisma/client.
-RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpx [email protected] generate --schema /triggerdotdev/internal-packages/database/prisma/schema.prisma +RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpx prisma@${PRISMA_VERSION} generate --schema /triggerdotdev/internal-packages/database/prisma/schema.prismaAdd near the start of the production-deps stage:
+ARG PRISMA_VERSION=6.14.0
39-39: Remove stale commented install line.Dead/commented code adds noise; drop it unless you plan to use it in this build stage.
apps/webapp/app/db.server.ts (1)
210-214: Consider handling $connect() errors explicitlyUnawaited connect can hide startup failures; at least log failures.
Apply:
- client.$connect(); + client.$connect().catch((err) => { + logger.error("PrismaClient connect failed", { clientType: "writer", err }); + });Repeat for replicaClient.$connect().
internal-packages/database/src/transaction.ts (5)
5-10: Avoid drift: derive TransactionIsolationLevel from Prisma typesManual string union can desync from Prisma.
Option:
- type TransactionIsolationLevel = - | "ReadUncommitted" - | "ReadCommitted" - | "RepeatableRead" - | "Serializable"; + import type { Prisma } from "../generated/prisma"; + type TransactionIsolationLevel = Prisma.TransactionIsolationLevel;Also applies to: 67-67
23-25: Transaction client detection may misclassify replica clientsBoth PrismaTransactionClient and PrismaReplicaClient are Omit<PrismaClient, "$transaction">, so this runtime check also returns true for a replica client if passed by mistake.
Options:
- Narrow the param type using the callback’s inferred tx type:
export type PrismaTransactionClient = Parameters<Parameters<PrismaClient["$transaction"]>[0]>[0];
- Or add a runtime guard that asserts the presence of known tx-only symbols and throw if a replica is detected.
Search call sites to ensure $transaction is never called with a replica client.
27-31: Type guard could be stricterOptional: also check name or use instanceof if safe.
Apply:
- return ( - typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" - ); + return ( + typeof error === "object" && + error !== null && + (error as any).code && + typeof (error as any).code === "string" && + typeof (error as any).message === "string" + );
79-111: Add backoff/jitter to retries to avoid thundering herdStraight immediate retries can amplify contention.
Apply:
- if ( + if ( retryCodes.includes(error.code) && typeof options?.maxRetries === "number" && attempt < options.maxRetries ) { - return $transaction(prisma, fn, prismaError, options, attempt + 1); + const base = 50; // ms + const delay = Math.min(1000, base * 2 ** attempt) + Math.floor(Math.random() * 50); + await new Promise((r) => setTimeout(r, delay)); + return $transaction(prisma, fn, prismaError, options, attempt + 1); }
113-142: Order-sensitive comparison in isUniqueConstraintErrormeta.target order may vary; compare sets instead.
Apply:
- if (target.length !== columns.length) { - return false; - } - - for (let i = 0; i < columns.length; i++) { - if (target[i] !== columns[i]) { - return false; - } - } - - return true; + if (target.length !== columns.length) return false; + const targetSet = new Set<string>(target); + return (columns as readonly string[]).every((c) => targetSet.has(c));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (2)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlreferences/v3-catalog/package.jsonis excluded by!references/**
📒 Files selected for processing (12)
.cursor/rules/webapp.mdc(2 hunks)apps/webapp/app/db.server.ts(1 hunks)apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.ts(1 hunks)apps/webapp/package.json(3 hunks)docker/Dockerfile(1 hunks)docker/docker-compose.yml(1 hunks)internal-packages/database/.dockerignore(1 hunks)internal-packages/database/.gitignore(1 hunks)internal-packages/database/package.json(1 hunks)internal-packages/database/prisma/schema.prisma(1 hunks)internal-packages/database/src/index.ts(1 hunks)internal-packages/database/src/transaction.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations
Files:
internal-packages/database/src/index.tsapps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.tsapps/webapp/app/db.server.tsinternal-packages/database/src/transaction.ts
internal-packages/database/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
We use prisma in internal-packages/database for our database interactions using PostgreSQL
Files:
internal-packages/database/src/index.tsinternal-packages/database/src/transaction.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
We use zod a lot in packages/core and in the webapp
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.tsapps/webapp/app/db.server.ts
apps/webapp/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
apps/webapp/**/*.{ts,tsx}: In the webapp, all environment variables must be accessed through theenvexport ofenv.server.ts, instead of directly accessingprocess.env.
When importing from@trigger.dev/corein the webapp, never import from the root@trigger.dev/corepath; always use one of the subpath exports as defined in the package's package.json.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.tsapps/webapp/app/db.server.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
📚 Learning: 2025-07-18T17:49:24.468Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
Applied to files:
internal-packages/database/src/index.tsinternal-packages/database/.dockerignoreinternal-packages/database/.gitignoreinternal-packages/database/package.jsonapps/webapp/app/db.server.tsinternal-packages/database/src/transaction.ts
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Import Trigger.dev APIs from "trigger.dev/sdk/v3" when writing tasks or related utilities
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-07-18T17:49:47.180Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, never import from the root `trigger.dev/core` path; always use one of the subpath exports as defined in the package's package.json.
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-07-18T17:49:24.468Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to {packages/core,apps/webapp}/**/*.{ts,tsx} : We use zod a lot in packages/core and in the webapp
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-07-18T17:49:47.180Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/app/v3/presenters/**/*.server.ts : Favor the use of 'presenters' to move complex loader code into a class, as seen in `app/v3/presenters/**/*.server.ts`.
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Do not use client.defineJob or any deprecated v2 patterns (e.g., eventTrigger) when defining tasks
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Define tasks using task({ id, run, ... }) with a unique id per project
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use schedules.task(...) for scheduled (cron) tasks; do not implement schedules as plain task() with external cron logic
Applied to files:
.cursor/rules/webapp.mdc
📚 Learning: 2025-07-18T17:49:47.180Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/app/services/**/*.server.ts : For testable services, separate service logic and configuration, as exemplified by `realtimeClient.server.ts` (service) and `realtimeClientGlobal.server.ts` (configuration).
Applied to files:
.cursor/rules/webapp.mdc
🧬 Code graph analysis (1)
internal-packages/database/src/transaction.ts (1)
apps/webapp/app/db.server.ts (3)
prisma(100-100)PrismaClientOrTransaction(21-21)PrismaTransactionClient(20-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (12)
apps/webapp/package.json (1)
218-218: @sentry/cli line moved — no functional changeNo action needed.
internal-packages/database/.gitignore (1)
4-5: Ignore generated Prisma client — LGTMMatches generator output path; keeps repo clean. Ensure CI runs
prisma generatebefore build steps.internal-packages/database/package.json (2)
8-10: Prisma 6.14.0 + decimal.js runtime — aligned and correctPinned Prisma versions are consistent; decimal.js inclusion matches code changes.
12-14: Prisma version consistency verifiedAll occurrences of
@prisma/clientandprismaacross the monorepo are pinned to6.14.0. No mixed client/runtime versions detected—no further changes needed.docker/Dockerfile (1)
41-41: All Prisma versions are already aligned at 6.14.xI’ve confirmed that:
- docker/Dockerfile pins the Prisma CLI to 6.14.0
- internal-packages/database has both @prisma/client and prisma at 6.14.0
- apps/webapp uses @prisma/instrumentation ^6.14.0 (covers 6.14.x)
No mismatches remain—no further changes needed.
internal-packages/database/.dockerignore (1)
1-5: Good call excluding generated client and preserving .env symlink.This keeps the Docker build context lean and avoids accidental env loss.
internal-packages/database/prisma/schema.prisma (1)
9-9: Output path change aligns with new re-export.Matches internal-packages/database/src/index.ts and the Docker generate step.
internal-packages/database/src/index.ts (1)
1-1: LGTM.Re-exporting from generated client matches the new generator output path.
apps/webapp/app/db.server.ts (1)
4-8: Type-only imports and $transaction consolidation look goodReduces bundle surface and clarifies value vs type usage.
internal-packages/database/src/transaction.ts (3)
1-3: Confirm stability of runtime type import@prisma/client/runtime/library is semi-internal; verify it’s stable in 6.14.0 or prefer a public type.
Option:
- import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"; + import type { Prisma } from "../generated/prisma"; + type PrismaClientKnownRequestError = Prisma.PrismaClientKnownRequestError;
21-21: Confirm Decimal compatibilityEnsure Prisma’s Decimal instances are compatible with decimal.js export for instanceof checks and serialization.
Quick runtime check in a dev shell after upgrading: create a Decimal field row, read it back, and assert
value instanceof Decimal.
38-46: Retriable error codes verified — complete set confirmedBased on the Prisma 6.14.0 error reference, the only known error codes recommended for automatic retry in interactive transactions are:
- P2024: Connection pool timeout (timed out fetching a new connection)
- P2028: Transaction API error (e.g., transaction expired or closed)
- P2034: Transaction conflict or deadlock (write conflict/deadlock)
No additional Prisma-thrown error codes are documented for retrying interactive transactions in version 6.14.0 (prisma.io)
| "@opentelemetry/semantic-conventions": "1.25.1", | ||
| "@popperjs/core": "^2.11.8", | ||
| "@prisma/instrumentation": "^5.11.0", | ||
| "@prisma/instrumentation": "^6.14.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
@prisma/instrumentation ^6.14.0 — version aligns with Prisma 6.14.0
Looks good. Please verify OTEL package versions don’t trigger peer warnings at runtime.
🏁 Script executed:
#!/bin/bash
# Check for mismatched OTEL deps that could cause peer warnings
jq -r '.dependencies, .devDependencies | to_entries[] | select(.key|test("^@opentelemetry/")).key + "@" + .value' apps/webapp/package.json
# Grep for Prisma instrumentation registration occurrences
rg -nP '@prisma/instrumentation|PrismaInstrumentation' -C2Length of output: 7998
Ensure OpenTelemetry dependency versions are fully aligned
- @prisma/instrumentation ^6.14.0 is correct and matches Prisma 6.14.0.
- In apps/webapp/package.json we have mixed OTel versions that will trigger peer-dependency warnings:
- @opentelemetry/[email protected] vs. core/resources/sdk packages at 1.25.1
- @opentelemetry/instrumentation-express@^0.36.1 vs. @opentelemetry/instrumentation & [email protected]
- These mismatches will surface at install/runtime. Please bump to a consistent set, for example:
- “@opentelemetry/api”: “^1.25.1”
- “@opentelemetry/instrumentation-express”: “^0.52.1”
- After updating, reinstall (pnpm/yarn) and confirm no peer warnings appear.
🤖 Prompt for AI Agents
In apps/webapp/package.json around line 81 the OpenTelemetry packages are
version-mismatched (e.g. @opentelemetry/[email protected] vs other otel packages at
1.25.1 and @opentelemetry/instrumentation-express@^0.36.1 vs
[email protected]); update package.json to align versions (set
"@opentelemetry/api" to "^1.25.1" and "@opentelemetry/instrumentation-express"
to "^0.52.1", and ensure any other @opentelemetry/* deps use the same
1.25.x/0.52.x family), then reinstall dependencies (pnpm/yarn) and confirm no
peer-dependency warnings at install/runtime.
| "dotenv": "^16.4.5", | ||
| "effect": "^3.11.7", | ||
| "emails": "workspace:*", | ||
| "eventsource": "^4.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
New dependency: eventsource — confirm module format and Node support
Ensure it works with your CJS server build and Node engine (>=16). Validate bundling and SSR usage.
🏁 Script executed:
#!/bin/bash
# Where is eventsource used?
rg -nP '\beventsource\b' -C2 apps/webapp | sed -n '1,120p'
# Quick ESM/CJS check via package.json fields (requires network if not installed)
# If workspace is installed, peek installed metadata:
fd -a 'eventsource/package.json' node_modules | xargs -I{} jq '{name:.name,module:.module,main:.main,types:.types,type:.type,engines:.engines}' {}Length of output: 484
🏁 Script executed:
#!/bin/bash
# Fetch module entrypoints and engine requirements for [email protected]
npm view [email protected] main module type engines --jsonLength of output: 645
[email protected] requires Node >= 20 and is published as ESM (with a CJS entrypoint)—verify runtime upgrade or pin to v3
The new “eventsource” dependency ships with
"type": "module"(so all.jsfiles are ESM),- a CJS entrypoint at
main: "./dist/index.cjs", - an ESM entrypoint at
module: "./dist/index.js", - and declares
"engines": { "node": ">=20.0.0" }.
This means:
- At install time, Node versions < 20 will be rejected by npm/yarn.
- Your CJS-based server can still
require('eventsource')(it’ll load the.cjsbuild), but bundlers/SSR pipelines may need explicit handling of.cjsmodules in an ESM package.
Please address:
- Whether you’re ready to upgrade your Node engine requirement to >= 20.0.0 to satisfy “eventsource”’s engines field.
- If not, consider pinning to the latest v3.x release (which supports Node >= 10 and is CJS).
- Confirm your bundler/SSR config correctly includes
.cjsfiles from ESM packages.
• File: apps/webapp/package.json (line 140)
• Dependency: "eventsource": "^4.0.0"
🤖 Prompt for AI Agents
In apps/webapp/package.json around line 140, the dependency "eventsource":
"^4.0.0" requires Node >=20 and ships as ESM with a CJS entrypoint; either
update the project's engine to "node": ">=20.0.0" (and bump CI/build images,
update lockfile and reinstall) if you are ready to run Node 20+, or pin
eventsource to the latest v3.x release (e.g. replace with "^3.x") to retain Node
<20 compatibility; additionally, if you keep v4, ensure your bundler/SSR config
explicitly allows importing .cjs files from ESM packages (adjust module/resolver
rules or transpile/include node_modules .cjs entries) and run a full build/test
to verify SSR and server-side require/import behavior.
nicktrn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a small comment re dockerignore and rabbit not quite happy yet but looks good otherwise!
8aaf750 to
594c0c4
Compare
Set the output to node_modules still to make it easier
594c0c4 to
ffb144d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal-packages/database/src/transaction.ts (1)
27-31: Type guard too permissive; may misclassify non‑Prisma errors with a string codeCurrent check matches any error with a string “code” (common in Node), which can incorrectly invoke prismaError() and possibly swallow non‑Prisma errors.
-import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"; +import type { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"; @@ -export function isPrismaKnownError(error: unknown): error is PrismaClientKnownRequestError { - return ( - typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" - ); -} +export function isPrismaKnownError(error: unknown): error is PrismaClientKnownRequestError { + // Prefer brand check; falls back to name to be resilient across bundles. + return ( + (typeof error === "object" && + error !== null && + // @ts-expect-error runtime check + (error instanceof Prisma.PrismaClientKnownRequestError || error.name === "PrismaClientKnownRequestError")) + ); +} @@ -export async function $transaction<R>( +export async function $transaction<R>( prisma: PrismaClientOrTransaction, fn: (prisma: PrismaTransactionClient) => Promise<R>, - prismaError: (error: PrismaClientKnownRequestError) => void, + prismaError: (error: PrismaClientKnownRequestError) => void,Also applies to: 3-3, 82-82
♻️ Duplicate comments (2)
apps/webapp/package.json (2)
81-81: Align OpenTelemetry versions to prevent peer warningsVersions are mixed (api 1.9.0 vs 1.25.1; express instrumentation ^0.36.x vs 0.52.x). Align to the 1.25.x/0.52.x family.
- "@opentelemetry/api": "1.9.0", + "@opentelemetry/api": "^1.25.1", - "@opentelemetry/instrumentation-express": "^0.36.1", + "@opentelemetry/instrumentation-express": "^0.52.1",#!/bin/bash # Verify all @opentelemetry/* versions align jq -r '.dependencies, .devDependencies | to_entries[] | select(.key|test("^@opentelemetry/")).key + "@" + .value' apps/webapp/package.json
140-140: eventsource@^4 requires Node >=20 — reconcile with engines or pin v3Your engines currently allow Node >=16. Choose one:
Option A (upgrade runtime): Update engines.node to ">=20.0.0".
Example (outside this hunk):{ "engines": { "node": ">=20.0.0" } }Option B (keep Node <20): Pin eventsource to v3.
- "eventsource": "^4.0.0", + "eventsource": "^3.0.2",
🧹 Nitpick comments (3)
.dockerignore (1)
19-20: Ignore the entire directory recursively and Prisma engines cacheThe current pattern will work, but making it explicit avoids edge cases and reduces context size further.
-**/generated/prisma +**/generated/prisma/** +# Also ignore Prisma engines cache that may appear in workspaces +**/.prisma/**docker/Dockerfile (1)
39-42: Parameterize Prisma CLI version and keep it in one placeAvoid hardcoding versions in multiple lines; makes future bumps safer.
-# RUN pnpm add @prisma/[email protected] -w ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true -RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpx [email protected] generate --schema /triggerdotdev/internal-packages/database/prisma/schema.prisma +ARG PRISMA_VERSION=6.14.0 +# RUN pnpm add @prisma/client@${PRISMA_VERSION} -w +RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpx prisma@${PRISMA_VERSION} generate --schema /triggerdotdev/internal-packages/database/prisma/schema.prismainternal-packages/database/src/transaction.ts (1)
5-10: Avoid manual isolation level strings; use Prisma’s type to prevent driftRelying on a local union risks mismatch with future Prisma changes. Use the official type.
-import { PrismaClient } from "../generated/prisma"; +import { PrismaClient, Prisma } from "../generated/prisma"; @@ -// Define the isolation levels manually -type TransactionIsolationLevel = - | "ReadUncommitted" - | "ReadCommitted" - | "RepeatableRead" - | "Serializable"; +type TransactionIsolationLevel = Prisma.TransactionIsolationLevel; @@ - /** Sets the transaction isolation level. By default this is set to the value currently configured in your database. */ - isolationLevel?: TransactionIsolationLevel; + /** Sets the transaction isolation level. By default this is set to the value currently configured in your database. */ + isolationLevel?: TransactionIsolationLevel;Also applies to: 66-68
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (12)
.cursor/rules/webapp.mdc(2 hunks).dockerignore(1 hunks)apps/webapp/app/db.server.ts(1 hunks)apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.ts(1 hunks)apps/webapp/package.json(3 hunks)docker/Dockerfile(1 hunks)docker/docker-compose.yml(1 hunks)internal-packages/database/.gitignore(1 hunks)internal-packages/database/package.json(1 hunks)internal-packages/database/prisma/schema.prisma(1 hunks)internal-packages/database/src/index.ts(1 hunks)internal-packages/database/src/transaction.ts(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- internal-packages/database/prisma/schema.prisma
- docker/docker-compose.yml
- apps/webapp/app/db.server.ts
- internal-packages/database/src/index.ts
- internal-packages/database/.gitignore
- internal-packages/database/package.json
- .cursor/rules/webapp.mdc
- apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations
Files:
internal-packages/database/src/transaction.ts
internal-packages/database/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
We use prisma in internal-packages/database for our database interactions using PostgreSQL
Files:
internal-packages/database/src/transaction.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
📚 Learning: 2025-07-18T17:49:24.468Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
Applied to files:
internal-packages/database/src/transaction.ts
🧬 Code graph analysis (1)
internal-packages/database/src/transaction.ts (1)
apps/webapp/app/db.server.ts (3)
prisma(100-100)PrismaClientOrTransaction(21-21)PrismaTransactionClient(20-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: units / packages / 📊 Merge Reports
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: typecheck / typecheck
🔇 Additional comments (2)
apps/webapp/package.json (1)
218-218: Move @sentry/cli to devDependencies — LGTMThis reduces prod image size and attack surface.
internal-packages/database/src/transaction.ts (1)
21-21: Decimal re-export — LGTMSwitching to decimal.js aligns with Prisma 6 runtime. Ensure decimal.js is a runtime dep of this package (it is per PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/webapp/app/db.server.ts (1)
1-399: Replace directprocess.env.VERY_SLOW_QUERY_THRESHOLD_MSusages with theenvwrapperDirect references to
process.env.VERY_SLOW_QUERY_THRESHOLD_MSwere found in two places and should be updated to use the importedenvobject for consistency and type safety:• apps/webapp/app/db.server.ts:159
• apps/webapp/app/db.server.ts:282Suggested diff:
- ...(process.env.VERBOSE_PRISMA_LOGS === "1" || - process.env.VERY_SLOW_QUERY_THRESHOLD_MS !== undefined + ...(env.VERBOSE_PRISMA_LOGS === "1" || + env.VERY_SLOW_QUERY_THRESHOLD_MS !== undefinedMake sure to update both the writer and replica client configurations accordingly.
🧹 Nitpick comments (5)
apps/webapp/app/utils/queryPerformanceMonitor.server.ts (3)
4-7: Prefer type alias over interface per repo guidelinesUse a type alias to match our TS style in webapp.
-export interface QueryPerformanceConfig { +export type QueryPerformanceConfig = { verySlowQueryThreshold?: number; // ms maxQueryLogLength: number; -} +}
35-52: Make param detection robust and avoid brittle string checksParse Prisma’s params payload when possible; fall back to regex. Also derive hasParams from the computed count.
- if (duration > this.config.verySlowQueryThreshold) { - // Truncate long queries for readability + if (duration > this.config.verySlowQueryThreshold) { + const paramCount = this.countParams(query, params); + // Truncate long queries for readability const truncatedQuery = query.length > this.config.maxQueryLogLength ? query.substring(0, this.config.maxQueryLogLength) + "..." : query; logger.error("Prisma: very slow database query", { clientType, durationMs: duration, query: truncatedQuery, target, timestamp, - paramCount: this.countParams(query), - hasParams: params !== "[]" && params !== "", + paramCount, + hasParams: paramCount > 0, }); }
55-59: Enhance countParams to use params JSON and support both $n and ? placeholdersThis improves accuracy across drivers and Prisma formats.
- private countParams(query: string): number { - // Count the number of $1, $2, etc. parameters in the query - const paramMatches = query.match(/\$\d+/g); - return paramMatches ? paramMatches.length : 0; - } + private countParams(query: string, paramsStr?: string): number { + // Prefer parsing Prisma's params payload if it's JSON-like + if (paramsStr) { + try { + const parsed = JSON.parse(paramsStr); + if (Array.isArray(parsed)) return parsed.length; + if (parsed && typeof parsed === "object") return Object.keys(parsed).length; + } catch { + // fall through to regex-based heuristics + } + } + // Heuristics: count $1, $2... (Postgres) or ? placeholders + const dollarParams = query.match(/\$\d+/g)?.length ?? 0; + const qmarkParams = query.match(/\?/g)?.length ?? 0; + return Math.max(dollarParams, qmarkParams); + }apps/webapp/app/db.server.ts (2)
168-175: Optional: move VERBOSE_PRISMA_LOGS to env schema for consistencyIf we want zero direct process.env usage in webapp, add VERBOSE_PRISMA_LOGS to EnvironmentSchema and consume via env.
291-298: Optional: same VERBOSE_PRISMA_LOGS consistency on replicaConsider routing via env schema.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/webapp/app/db.server.ts(5 hunks)apps/webapp/app/env.server.ts(1 hunks)apps/webapp/app/utils/queryPerformanceMonitor.server.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations
Files:
apps/webapp/app/utils/queryPerformanceMonitor.server.tsapps/webapp/app/env.server.tsapps/webapp/app/db.server.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
We use zod a lot in packages/core and in the webapp
Files:
apps/webapp/app/utils/queryPerformanceMonitor.server.tsapps/webapp/app/env.server.tsapps/webapp/app/db.server.ts
apps/webapp/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
apps/webapp/**/*.{ts,tsx}: In the webapp, all environment variables must be accessed through theenvexport ofenv.server.ts, instead of directly accessingprocess.env.
When importing from@trigger.dev/corein the webapp, never import from the root@trigger.dev/corepath; always use one of the subpath exports as defined in the package's package.json.
Files:
apps/webapp/app/utils/queryPerformanceMonitor.server.tsapps/webapp/app/env.server.tsapps/webapp/app/db.server.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
📚 Learning: 2025-07-18T17:49:24.468Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL
Applied to files:
apps/webapp/app/db.server.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: typecheck / typecheck
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
apps/webapp/app/env.server.ts (1)
1083-1085: Env var addition looks goodOptional numeric threshold with coercion aligns with how other timing envs are defined.
apps/webapp/app/utils/queryPerformanceMonitor.server.ts (1)
62-64: LGTM: env-driven threshold wiringSingleton configured from env keeps this opt-in by default.
apps/webapp/app/db.server.ts (4)
4-9: Type-only imports and $transaction aliasing look correctThis reduces type bloat and keeps the runtime alias consistent.
18-18: LGTM: query performance monitor integrationImport placement and usage are appropriate.
216-220: LGTM: writer query event hookListener is safe; emits only when query events are enabled.
338-342: LGTM: replica query event hookSymmetric with writer, correct clientType passed.