drizzle-team / drizzle-team/drizzle-orm

[BUG]: Drizzle ORM does not throw error when PostgreSQL server is unreachable

Open
#3,572 2 comments 3 reactions 0 assignees View on GitHub
improvement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [X] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

0.36.3

### What version of `drizzle-kit` are you using?

0.28.1

### Other packages

_No response_

### Describe the Bug

When attempting to connect to a PostgreSQL database that is not running, Drizzle ORM does not throw an error as expected. This silent failure makes it difficult to implement proper error handling and could lead to unexpected behavior in production environments.

Current Behavior
- No error is thrown when the PostgreSQL server is not running
- The application continues to run without indicating connection failure

Expected Behavior
- Drizzle should throw an error when unable to establish a connection with PostgreSQL
- Connection failure should be immediately apparent

Steps to Reproduce
```
import { FastifyInstance } from "fastify";
import { drizzle, NodePgDatabase } from "drizzle-orm/node-postgres";
import * as schema from "../db/schema";
import fp from "fastify-plugin";

export type db = NodePgDatabase;

// TODO: not throwing error when postgres is not running
async function db(app: FastifyInstance) {
const db = drizzle(app.config.DATABASE_URL, {
schema: schema,
});

app.decorate("db", db);
}

export default fp(db);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.