fix: improve Prisma version resolution for pnpm workspaces
Summary
- Fixed package.json resolution bug that could select wrong package in pnpm workspaces
- Added fallback to read version directly from node_modules when primary detection fails
- Added support for workspace: protocol and helpful error messages for catalog: references
Problem
When using pnpm workspaces without an explicit version in trigger.config.ts, the Prisma extension could fail to detect or select the wrong version due to:
- Package.json resolution finding parent workspace package.json instead of @prisma/client's
- No support for pnpm catalog: or workspace: version specifiers
Fixes #2556
Solution
- Fixed root cause: Added verification that resolved package.json belongs to the correct package
-
Added robust fallback: Read directly from
node_modules/@prisma/client/package.jsonwhen primary detection fails - Better error messages: Detect catalog: references and provide clear guidance
- Zero new dependencies: Solution uses only existing dependencies
Test Plan
- [ ] Verify Prisma extension works with regular npm/yarn projects
- [ ] Test with pnpm workspace using workspace: protocol
- [ ] Test with pnpm catalog references (should get helpful error)
- [ ] Verify fallback to node_modules reading works when externals detection fails
🤖 Generated with Claude Code
🦋 Changeset detected
Latest commit: d128d50e5ec26ea708403adb1349186293b8792c
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 23 packages
| Name | Type |
|---|---|
| @trigger.dev/build | Patch |
| trigger.dev | Patch |
| @trigger.dev/python | Patch |
| d3-chat | Patch |
| references-d3-openai-agents | Patch |
| references-nextjs-realtime | Patch |
| @trigger.dev/core | Patch |
| @trigger.dev/react-hooks | Patch |
| @trigger.dev/redis-worker | Patch |
| @trigger.dev/rsc | Patch |
| @trigger.dev/schema-to-json | Patch |
| @trigger.dev/sdk | Patch |
| @trigger.dev/database | Patch |
| @trigger.dev/otlp-importer | Patch |
| @internal/cache | Patch |
| @internal/clickhouse | Patch |
| @internal/redis | Patch |
| @internal/replication | Patch |
| @internal/run-engine | Patch |
| @internal/schedule-engine | Patch |
| @internal/testcontainers | Patch |
| @internal/tracing | Patch |
| @internal/zod-worker | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Walkthrough
The build package enhances @prisma/client version resolution by falling back to reading the installed node_modules/@prisma/client package.json and, if needed, inspecting the project package.json (via resolvePackageJSON) for dependencies/devDependencies, handling catalog: and workspace: specifiers and throwing a clear error for unresolved workspace references. It adds debug logs. The CLI externals resolution now validates that a discovered package.json's name matches the originally resolved package name and aborts the extern resolution on mismatch before applying existing filters.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description Check | ⚠️ Warning | The PR description does not follow the repository template, as it omits the required checklist, the “Closes # |
Please update the PR description to use the provided template by adding the “Closes #2556” header, completing the checklist, and including the Testing, Changelog, and Screenshots sections. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | ✅ Passed | The title concisely describes the primary intent of the changeset, namely improving Prisma version resolution for pnpm workspaces, and aligns with the main modifications in the code. |
| Linked Issues Check | ✅ Passed | The changes implement all coding requirements from issue #2556 by verifying the correct package.json during resolution, adding a fallback to read the version from node_modules, supporting pnpm workspace specifiers, detecting catalog references with clear errors, and preventing misidentification in externals resolution. |
| Out of Scope Changes Check | ✅ Passed | All code modifications focus on enhancing Prisma version detection and external resolution logic as described in the linked issue objectives, with no unrelated or out-of-scope changes introduced. |
| Docstring Coverage | ✅ Passed | No functions found in the changes. Docstring coverage check skipped. |
✨ Finishing touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0e4e7d5e37230bc1d36a645047daa6aaf93b2021 and d128d50e5ec26ea708403adb1349186293b8792c.
📒 Files selected for processing (1)
-
.changeset/light-sheep-vanish.md(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .changeset/light-sheep-vanish.md
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
This has been fixed in 4.1.1