You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing this in my express app to gracefully disconnect from postgres. Is this not better? I don't see anything like this in your express example unless I'm missing it:
...other code
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
const gracefulPrismaPostgresShutdown = async () => {
console.log("Shutting down prisma postgres connection gracefully...");
await prisma.$disconnect();
process.exit(0);
};
// Handle termination signals
process.on("SIGINT", gracefulPrismaPostgresShutdown);
process.on("SIGTERM", gracefulPrismaPostgresShutdown);
app.use(async (err, req, res, next) => {
if (err) {
console.error("Unhandled error:", err);
await prisma.$disconnect(); // Ensure disconnect
respondError(res, err ?? "Technical Error");
}
next();
});
// Set up global middleware
app.use(cors(), express.json(), authenticateJWT);
/**
* ROUTES
*/
// Get all subscriptions
app.get("/subscriptions", (req, res, next) => {
subscriptionsGet(req, res, next);
});
The text was updated successfully, but these errors were encountered:
I'm doing this in my express app to gracefully disconnect from postgres. Is this not better? I don't see anything like this in your express example unless I'm missing it:
The text was updated successfully, but these errors were encountered: