Repository navigation
bug: prismaExtension's version detection only works when "@prisma/client" is added to additionalPackages #1480
Description
Provide environment information
System:
OS: macOS 15.1
CPU: (11) arm64 Apple M3 Pro
Memory: 133.08 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.0 - /opt/homebrew/opt/node@20/bin/node
npm: 10.8.2 - /opt/homebrew/opt/node@20/bin/npm
pnpm: 9.12.3 - /opt/homebrew/opt/node@20/bin/pnpm
Describe the bug
Running pnpm dlx trigger.dev@latest deploy fails when using prismaExtension's default config.
Based on this doc, the prismaExtension should automatically detect the installed version. Without a version, the deployment succeeds and silently reports an error:
% pnpm trigger deploy
Trigger.dev (3.2.0)
------------------------------------------------------
┌ Deploying project
│
◇ Retrieved your account details for ...
│
◇ Successfully built project
✘ [ERROR] Failed to apply extension PrismaExtension onBuildComplete Error: PrismaExtension could not determine the version of @prisma/client. It's possible that the @prisma/client was not used in the project. If this isn't the case, please provide a version in the PrismaExtension options.
at PrismaExtension.onBuildComplete
(/Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/@trigger.dev+build@3.2.0_typescript@5.6.3/node_modules/@trigger.dev/build/dist/commonjs/extensions/prisma.js:55:19)
at notifyExtensionOnBuildComplete
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/build/extensions.js:16:33)
at async buildWorker
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/build/buildWorker.js:70:21)
at async _deployCommand
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/commands/deploy.js:120:27)
at async
file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/commands/deploy.js:77:16
at async
file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/cli/common.js:54:28
at async wrapCommandAction
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/cli/common.js:40:12)
at async deployCommand
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/commands/deploy.js:76:12)
at async
file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/commands/deploy.js:71:13
at async handleTelemetry
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/cli/common.js:30:9)
at async Command.<anonymous>
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/commands/deploy.js:69:9)
at async Command.parseAsync
(/Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/command.js:935:5)
at async main
(file:///Users/guillaume/alephic/trigger-prisma-bug/node_modules/.pnpm/trigger.dev@3.2.0_typescript@5.6.3/node_modules/trigger.dev/dist/esm/index.js:5:5)
│
◇ Successfully deployed version 20241117.8
│
└ Version 20241117.8 deployed with 1 detected task When adding version: "5.22.0", the deployment fails entirely:
% pnpm trigger deploy
Trigger.dev (3.2.0)
------------------------------------------------------
┌ Deploying project
│
◇ Retrieved your account details for ...
│
◇ Successfully built project
▲ [WARNING] prismaExtension could not resolve the DATABASE_URL environment variable. Make sure you add it to your environment variables. See our docs for more info: https://trigger.dev/docs/deploy-environment-variables
│
◇ Failed to deploy project
│
└ Error: Error building image. Full build logs have been saved to /var/folders/4j/sp9fwh5s369b28x_jjckbgd40000gn/T/trigger-Z2WsDu/build-gwivrttk.logHere's a snippet of the build error:
------
> [build 6/7] RUN node node_modules/prisma/build/index.js generate --schema=./prisma/schema.prisma:
#17 0.456 Prisma schema loaded from prisma/schema.prisma
#17 0.579 Error: Command failed with ENOENT: pnpm add @prisma/client@5.22.0 --silent
#17 0.579 spawn pnpm ENOENT
------
Error: failed to solve: process "/bin/sh -c node node_modules/prisma/build/index.js generate --schema=./prisma/schema.prisma" did not complete successfully: exit code: 1
Workaround
Adding "@prisma/client" to additionalPackages fixes the issue:
import { defineConfig } from "@trigger.dev/sdk/v3";
import { additionalPackages } from "@trigger.dev/build/extensions/core";
import { prismaExtension } from "@trigger.dev/build/extensions/prisma";
export default defineConfig({
build: {
extensions: [
prismaExtension({ schema: "prisma/schema.prisma" }),
additionalPackages({ packages: ["@prisma/client@5.22.0"] }),
]
}
})Reproduction repo
https://github.com/gmathieu/trigger-prisma-bug
To reproduce
- Check out the https://github.com/gmathieu/trigger-prisma-bug
- run
pnpm install - Replace
projectwith your project ID intrigger.config.ts
Note: Don't worry about DATABASE_URL warnings, we're only testing the deployment cycle.
Scenario 1: silent failure
- run
pnpm trigger deploy
Scenario 2: build failure with version
- Uncomment the version
- run
pnpm trigger deploy
Scenario 3: successful deployment with additionalPackages
- Uncomment additionalPackages
- run
pnpm trigger deploy
Note: additionalPackages properly populates the manifest's externals here, so version can be omitted.
Additional information
No response
Activity
Cirr0e commentedon Nov 25, 2024
Hi! I understand the issue you're experiencing with the
prismaExtension's version detection. This appears to be a known limitation in how the extension currently works with Prisma dependencies.Here's how to resolve this issue:
trigger.config.tsto use both theprismaExtensionandadditionalPackagestogether:This configuration ensures that:
@prisma/clientis available during buildBe aware that:
@prisma/clientto what's in your project's package.jsonThis is currently the recommended workaround until the version detection functionality is improved in a future release.
Let me know if you need any clarification or run into any other issues!
RobertHH-IS commentedon Dec 14, 2024
the build also fails if using prismaSchemaFolder extension.
If schema.prisma
`generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions", "prismaSchemaFolder", "fullTextSearchPostgres"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
`
And then you create other.prisma and user.prisma.. everything works fine in NextJS.. however trigger.dev build says that schema.prisma is empty and errors out.
rharkor commentedon Feb 3, 2025
Yes, I'm currently having the same issue..
matt-aitken commentedon Feb 3, 2025
@rharkor can you share your
trigger.configfile?We do support the folders, by following the convention that the enclosing folder should be called
schema. You can see the code here:trigger.dev/packages/build/src/extensions/prisma.ts
Line 115 in 6f52b00
I know that people are using this, so maybe there's some new case here we don't deal with
rharkor commentedon Feb 4, 2025
Hey thanks for the reply, I've found the issue, it was because I am currently using multiple databases so I finally made my own small extension to handle that, if anyone have the same problem feel free to check the code below (please note that the paths aren't dynamic)
matt-aitken commentedon Feb 4, 2025
@rharkor nice!
matt-aitken commentedon Aug 29, 2026
The Prisma extension has been rewritten. It now detects the Prisma version without
additionalPackages. Closing as outdated.