feat(server): graceful shutdown for AI streams (#10025)

https://github.com/user-attachments/assets/8dd3c4f5-4059-4f03-9f51-68078d7ab5c4
This commit is contained in:
Brooooooklyn
2025-02-07 11:25:02 +00:00
parent 0df94b8e35
commit 4e00ddd5f1
3 changed files with 42 additions and 12 deletions

View File

@@ -1,11 +1,11 @@
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import type { OnApplicationShutdown, OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { Prisma, PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService
extends PrismaClient
implements OnModuleInit, OnModuleDestroy
implements OnModuleInit, OnApplicationShutdown
{
static INSTANCE: PrismaService | null = null;
@@ -18,7 +18,7 @@ export class PrismaService
await this.$connect();
}
async onModuleDestroy(): Promise<void> {
async onApplicationShutdown(): Promise<void> {
if (!AFFiNE.node.test) {
await this.$disconnect();
PrismaService.INSTANCE = null;