#Prisma V7 Error: Client Password must be a string

9 messages · Page 1 of 1 (latest)

cinder comet
#

Hey! I am sorry if it's asked already, I just migrated to Prisma V7 and am stuck with an unsolvable error.

SCRAM-SERVER-FIRST-MESSAGE: client password must be a string

The server runs fine, Though the error only occurs when i change the database using Prisma on API calls.

I have verified the version of prisma client, Prisma and Prisma adapter, All are V 7.01.

This is how I initialize prisma:

import { PrismaClient } from "../../generated/prisma/client.js";
import { PrismaPg } from "@prisma/adapter-pg";
import dotenv from "dotenv";

const adapter = new PrismaPg({
    connectionString: process.env.DATABASE_URL
});

const prismaClientSingleton = () => {
    dotenv.config();
    console.log("DATABASE_URL =", process.env.DATABASE_URL);
    return new PrismaClient({
        adapter: adapter
    });
};
declare const globalThis: {
    prismaGlobal: ReturnType<typeof prismaClientSingleton>
} & typeof global;

const prisma: PrismaClient = globalThis.prismaGlobal ?? prismaClientSingleton();

if (process.env.NODE_ENV !== "production") {
    globalThis.prismaGlobal = prisma;
};

export default prisma;

My Prisma.config:

import { defineConfig, env } from "prisma/config";
import "dotenv/config";

export default defineConfig({
    schema: "prisma/schema.prisma",
    migrations: {
        path: "prisma/migrations"
    },
    datasource: {
        url: env("DATABASE_URL"),
        shadowDatabaseUrl: env("DIRECT_URL")
    }
});

I have made sure My DB URL isnt null:

> [email protected] dev
> nodemon start

[nodemon] 3.1.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node start dist/index.js`
[[email protected]] injecting env (9) from .env -- tip: 📡 version env with Radar: https://dotenvx.com/radar
DATABASE_URL = postgresql://postgres:EducatorSQLSchool@localhost:5432/authentication_fullstack

All help would be appreciated!

bronze belfryBOT
#

You selected to wait for the human sages. They'll share their wisdom soon.

Grab some tea while you wait, or check out #ask-ai if you'd like a quick chat with the bot anyway!

river edge
#

happened to me only in production in nuxt 3, had to set environment variable of DATABASE_URL before running the server because dotenv does not work in production, you shoul set environment variables in another way. Like SET cmdlet.

wooden crater
#

Hmm, I haven't seen this error before. Did this start happening only after updating to Prisma 7?

cinder comet
cinder comet
# river edge happened to me only in production in nuxt 3, had to set environment variable of ...

Ok thanks will try it, Though I dont think thats the issue as I console.log the DATABASE_URL when initiliazing and it doesnt seem to be null.

import { PrismaClient } from "../../generated/prisma/client.js";
import { PrismaPg } from "@prisma/adapter-pg";
import dotenv from "dotenv";

const adapter = new PrismaPg({
    connectionString: process.env.DATABASE_URL
});

const prismaClientSingleton = () => {
    dotenv.config();
    console.log("DATABASE_URL =", process.env.DATABASE_URL);
    return new PrismaClient({
        adapter: adapter
    });
};

river edge
#

honestly just stick with whatever version is working

#

v7 is not stable now

past sinew
#

I notice you are only calling dotenv.config() after attempting to use an environment variable the first time. dotenv usually works best when its the first import, and the config is called immediately.

I'm not sure it fixes anything, but its worth a shot.

If you're interested in a minimal reproduction that works, have a glance here:
https://github.com/aarhusgregersen/prisma-seed-minimal-reproduction/tree/feat/prisma-7

GitHub

Minimal reproduction of prisma seed issue in monorepo - GitHub - aarhusgregersen/prisma-seed-minimal-reproduction at feat/prisma-7