Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(infra): type the export cleanup wait and its query spy strictly
Yudhi Armyndharis393a30c8d3ac
diff --git a/src/modules/infra/infra-data.controller.spec.ts b/src/modules/infra/infra-data.controller.spec.tsindex f096dfa73..6518e9970 100644--- a/src/modules/infra/infra-data.controller.spec.ts+++ b/src/modules/infra/infra-data.controller.spec.ts@@ -389,9 +389,9 @@ describe('InfraDataController.importData round-trips export-data (no silent mess// The export reads each table separately, so a session paired mid-export is missing from the// archive while a child row written for it before its table is read is not.const query = ds.query.bind(ds);- jest.spyOn(ds, 'query').mockImplementation(async (sql: string, params?: unknown[]) => {- const rows: unknown = await query(sql, params);- if (sql === 'SELECT * FROM sessions') {+ jest.spyOn(ds, 'query').mockImplementation(async (...args: Parameters<DataSource['query']>) => {+ const rows: unknown = await query(...args);+ if (args[0] === 'SELECT * FROM sessions') {await seedSession('s2');await ds.getRepository(Template)diff --git a/src/modules/infra/infra-storage.controller.ts b/src/modules/infra/infra-storage.controller.tsindex 2031b72bc..7f4c017a3 100644--- a/src/modules/infra/infra-storage.controller.ts+++ b/src/modules/infra/infra-storage.controller.ts@@ -199,7 +199,7 @@ export class InfraStorageController implements OnApplicationBootstrap {// The TTL sweep below only covers a finished archive; a failed one would otherwise stay on the// data volume until a restart a day later. Wait for the sink to close so the unlink cannot race// an open that is still pending.- if (!writeStream.closed) await new Promise(resolve => writeStream.once('close', resolve));+ if (!writeStream.closed) await new Promise<void>(resolve => writeStream.once('close', () => resolve()));await fs.promises.unlink(exportPath).catch(() => undefined);throw error;}