NestJS + Prisma 7 + Planetscale
Hi, I iave a some issue but I cant figute out why.
6 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai for a quick spin!my package.json
and prisma.service.ts
But I got:
"@planetscale/database": "^1.19.0",
"@prisma/adapter-planetscale": "^7.0.0",
"@prisma/client-runtime-utils": "7.0.0",
"@prisma/client": "^7.0.0",
"@planetscale/database": "^1.19.0",
"@prisma/adapter-planetscale": "^7.0.0",
"@prisma/client-runtime-utils": "7.0.0",
"@prisma/client": "^7.0.0",
constructor(private readonly configService: ConfigService) {
const databaseUrl = configService.get('DATABASE_URL');
if (!databaseUrl) {
throw new Error('DATABASE_URL is not defined');
}
const planetscaleClient = new Client({ url: databaseUrl });
const adapter = new PrismaPlanetScale(planetscaleClient);
super({ adapter });
}
...
constructor(private readonly configService: ConfigService) {
const databaseUrl = configService.get('DATABASE_URL');
if (!databaseUrl) {
throw new Error('DATABASE_URL is not defined');
}
const planetscaleClient = new Client({ url: databaseUrl });
const adapter = new PrismaPlanetScale(planetscaleClient);
super({ adapter });
}
...
ypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async postJSON (~/node_modules/.pnpm/@planetscale+database@1.19.0/node_modules/@planetscale/database/dist/cjs/index.js:134:22)
at async Connection.execute (~/node_modules/.pnpm/@planetscale+database@1.19.0/node_modules/@planetscale/database/dist/cjs/index.js:89:23)
at async PrismaPlanetScaleAdapter.performIO (~/node_modules/.pnpm/@prisma+adapter-planetscale@7.0.0/node_modules/@prisma/adapter-planetscale/dist/index.js:348:22)
at async PrismaPlanetScaleAdapter.queryRaw (~/node_modules/.pnpm/@prisma+adapter-planetscale@7.0.0/node_modules/@prisma/adapter-planetscale/dist/index.js:321:54)
at async <anonymous> (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/tracing.ts:68:22)
at async mr (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/tracing.ts:56:10)
at async e.interpretNode (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:175:26)
at async e.interpretNode (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:202:41)
ypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async postJSON (~/node_modules/.pnpm/@planetscale+database@1.19.0/node_modules/@planetscale/database/dist/cjs/index.js:134:22)
at async Connection.execute (~/node_modules/.pnpm/@planetscale+database@1.19.0/node_modules/@planetscale/database/dist/cjs/index.js:89:23)
at async PrismaPlanetScaleAdapter.performIO (~/node_modules/.pnpm/@prisma+adapter-planetscale@7.0.0/node_modules/@prisma/adapter-planetscale/dist/index.js:348:22)
at async PrismaPlanetScaleAdapter.queryRaw (~/node_modules/.pnpm/@prisma+adapter-planetscale@7.0.0/node_modules/@prisma/adapter-planetscale/dist/index.js:321:54)
at async <anonymous> (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/tracing.ts:68:22)
at async mr (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/tracing.ts:56:10)
at async e.interpretNode (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:175:26)
at async e.interpretNode (~/node_modules/.pnpm/@prisma+client@7.0.0_prisma@7.0.0_@types+react@19.1.8_react-dom@19.1.0_react@19.1.0__re_6c07031c17b2a70f18f834c547a9f3ea/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:202:41)
can you show me full prisma.service.ts ?
hi @Aman, here my sv:
import {
INestApplication,
Injectable,
OnModuleDestroy,
OnModuleInit,
} from '@nestjs/common';
import { PrismaClient } from './generated/client';
import { PrismaPlanetScale } from '@prisma/adapter-planetscale';
import { Client } from '@planetscale/database';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
constructor() {
const databaseUrl = process.env.DATABASE_URL;
if (!databaseUrl) {
throw new Error('DATABASE_URL is not defined');
}
const planetscaleClient = new Client({ url: databaseUrl });
const adapter = new PrismaPlanetScale(planetscaleClient);
super({ adapter });
}
async onModuleInit() {
await this.$connect();
}
async onModuleDestroy() {
await this.$disconnect();
}
async enableShutdownHooks(app: INestApplication) {
process.on('exit', async () => await app.close());
}
}
import {
INestApplication,
Injectable,
OnModuleDestroy,
OnModuleInit,
} from '@nestjs/common';
import { PrismaClient } from './generated/client';
import { PrismaPlanetScale } from '@prisma/adapter-planetscale';
import { Client } from '@planetscale/database';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
constructor() {
const databaseUrl = process.env.DATABASE_URL;
if (!databaseUrl) {
throw new Error('DATABASE_URL is not defined');
}
const planetscaleClient = new Client({ url: databaseUrl });
const adapter = new PrismaPlanetScale(planetscaleClient);
super({ adapter });
}
async onModuleInit() {
await this.$connect();
}
async onModuleDestroy() {
await this.$disconnect();
}
async enableShutdownHooks(app: INestApplication) {
process.on('exit', async () => await app.close());
}
}
Just to confirm when you say PlanetScale, do you mean PlanetScale Postgres or PlanetScale MySQL?
ah mysql