Skip to content

$connect() always succeeds in Prisma v7 using @prisma/adapter-pg even when DB is unreachable #28896

Closed

Description

@dev-ibiske

Bug description


🐛 Bug Report — $connect() succeeds even when DB is offline in Prisma v7 using @prisma/adapter-pg

Summary

After upgrading to Prisma v7 and switching to the @prisma/adapter-pg adapter, calling $connect() no longer throws an error when the PostgreSQL server is offline.

Instead, it logs a successful connection, which makes startup and health checks unreliable.

How to Reproduce

  1. Stop PostgreSQL service

  2. Start a NestJS or Node.js application that calls await prisma.$connect()

  3. Observe: Prisma reports a successful connection even though the DB is down

Expected Behavior

$connect() should fail immediately with a connection error if the database is unreachable — matching the behavior in Prisma < v7.

Actual Behavior

  • $connect() completes successfully

  • Shows "Prisma connected" log message

  • No exception is thrown until the first query is executed later

Terminal Output Screenshot

Image

NestJS log showing “Prisma connected” while DB is offline

PostgreSQL Service Status Screenshot

Image

Postgres service stopped / disabled

Code Example

import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from 'prisma/generated/prisma/client';

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
private readonly logger = new Logger(PrismaService.name);

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

async onModuleInit() {
try {
await this.$connect();
this.logger.log('Prisma connected');
} catch (e) {
this.logger.error('Prisma connection error', e);
}
}
}

Environment

Component Version
Prisma 7.x.x
Adapter @prisma/adapter-pg
DB PostgreSQL
Runtime NestJS (also reproducible in plain Node)
OS (windows)
Node.js (20.19.5)

Additional Context

This appears to be a regression introduced with the new PG adapter + connection-less architecture. It causes production systems to falsely assume database health, breaking readiness checks.

Severity

🚨 Critical: Data loss, app crash, security issue

Reproduction

Expected vs. Actual Behavior


🐛 Bug Report — $connect() succeeds even when DB is offline in Prisma v7 using @prisma/adapter-pg

Summary

After upgrading to Prisma v7 and switching to the @prisma/adapter-pg adapter, calling $connect() no longer throws an error when the PostgreSQL server is offline.

Instead, it logs a successful connection, which makes startup and health checks unreliable.

How to Reproduce

  1. Stop PostgreSQL service

  2. Start a NestJS or Node.js application that calls await prisma.$connect()

  3. Observe: Prisma reports a successful connection even though the DB is down

Expected Behavior

$connect() should fail immediately with a connection error if the database is unreachable — matching the behavior in Prisma < v7.

Actual Behavior

  • $connect() completes successfully

  • Shows "Prisma connected" log message

  • No exception is thrown until the first query is executed later

Terminal Output Screenshot

Image

NestJS log showing “Prisma connected” while DB is offline

PostgreSQL Service Status Screenshot

Image

Postgres service stopped / disabled

Code Example

import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from 'prisma/generated/prisma/client';

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
private readonly logger = new Logger(PrismaService.name);

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

async onModuleInit() {
try {
await this.$connect();
this.logger.log('Prisma connected');
} catch (e) {
this.logger.error('Prisma connection error', e);
}
}
}

Environment

Component Version
Prisma 7.x.x
Adapter @prisma/adapter-pg
DB PostgreSQL
Runtime NestJS (also reproducible in plain Node)
OS (windows)
Node.js (20.19.5)

Activity

  1. added
    kind/bug
    on Dec 10, 2025
  2. added
    bug/2-confirmed
    on Dec 10, 2025
  3. added 4 commits that reference this issue on Dec 16, 2025
    2800492
    3b8e867
    1fdc311
    1561f97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedkind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions