PrismaP
Prisma2y ago
10 replies
AirmanEpic

Prisma is throwing __filename is not defined specifically in SST cron jobs

This is a weird issue, when I'm running prisma through SST's cron job, which I need in order to do database processing tasks, I get an error that says
__filename is not defined
and the cron job fails. I've tried a workaround with

import type { PrismaClient as PrismaClientType } from '@prisma/client';
import { createRequire } from 'module';

const require = createRequire(import.meta.url ?? __filename);
const { PrismaClient: PrismaClientImpl } = require('@prisma/client');
export class PrismaClient extends (PrismaClientImpl as typeof PrismaClientType) {}


but unfortunately this doesn't seem to disconnect the prisma client ever or something, and so I get errors down the line because there are too many prisma clients connected.
Was this page helpful?