From 636daca703e40101723da06a5af2a4279b1db2b8 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Wed, 17 Jun 2026 14:57:52 +0330 Subject: [PATCH] fix: improve Redis client shutdown handling to avoid errors --- .../saleInvoices/sale-invoice-create.service.ts | 1 + src/redis/redis.service.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/services/saleInvoices/sale-invoice-create.service.ts b/src/common/services/saleInvoices/sale-invoice-create.service.ts index b4f9726..96e83a1 100644 --- a/src/common/services/saleInvoices/sale-invoice-create.service.ts +++ b/src/common/services/saleInvoices/sale-invoice-create.service.ts @@ -401,6 +401,7 @@ export class SharedSaleInvoiceCreateService { customer, payments, settlement_type, + send_to_tsp, ...invoiceData } = data diff --git a/src/redis/redis.service.ts b/src/redis/redis.service.ts index 1f69ec4..b0442e6 100644 --- a/src/redis/redis.service.ts +++ b/src/redis/redis.service.ts @@ -252,6 +252,17 @@ export class RedisService implements OnModuleDestroy { } async onModuleDestroy() { - await this.client.quit() + if (this.client.status === 'end') { + return + } + + try { + await this.client.quit() + } catch (error) { + const message = (error as Error)?.message || '' + if (!message.includes('Connection is closed')) { + this.logger.warn(`Redis shutdown failed: ${message}`) + } + } } }