From 1e102d1750347bc1701737c4141962c0e6a864c1 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 18 Feb 2026 10:37:50 +0100 Subject: [PATCH 1/2] flush --- packages/core/src/client.ts | 1 + packages/core/test/lib/client.test.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 588c8a62e97e..2a06ee28b535 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -445,6 +445,7 @@ export abstract class Client { */ // @ts-expect-error - PromiseLike is a subset of Promise public async close(timeout?: number): PromiseLike { + _INTERNAL_flushLogsBuffer(this); const result = await this.flush(timeout); this.getOptions().enabled = false; this.emit('close'); diff --git a/packages/core/test/lib/client.test.ts b/packages/core/test/lib/client.test.ts index 014ffe8ebbe1..6e34eba47fb6 100644 --- a/packages/core/test/lib/client.test.ts +++ b/packages/core/test/lib/client.test.ts @@ -13,6 +13,7 @@ import { withMonitor, } from '../../src'; import * as integrationModule from '../../src/integration'; +import * as logsInternalModule from '../../src/logs/internal'; import { _INTERNAL_captureLog } from '../../src/logs/internal'; import { _INTERNAL_captureMetric } from '../../src/metrics/internal'; import * as traceModule from '../../src/tracing/trace'; @@ -2212,6 +2213,22 @@ describe('Client', () => { expect(getSentCount()).toBe(1); }); + test('close flushes the logs buffer', async () => { + vi.useRealTimers(); + + const flushLogsSpy = vi.spyOn(logsInternalModule, '_INTERNAL_flushLogsBuffer').mockImplementation(() => undefined); + + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); + const client = new TestClient(options); + + await client.close(); + + expect(flushLogsSpy).toHaveBeenCalledTimes(1); + expect(flushLogsSpy).toHaveBeenCalledWith(client); + + flushLogsSpy.mockRestore(); + }); + test('multiple concurrent flush calls should just work', async () => { vi.useRealTimers(); expect.assertions(3); From a132921dc69c6be93b3b5edfa34ad00b933db620 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 18 Feb 2026 10:45:50 +0100 Subject: [PATCH 2/2] fmt --- packages/core/test/lib/client.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/test/lib/client.test.ts b/packages/core/test/lib/client.test.ts index 6e34eba47fb6..35438866c6c2 100644 --- a/packages/core/test/lib/client.test.ts +++ b/packages/core/test/lib/client.test.ts @@ -2216,7 +2216,9 @@ describe('Client', () => { test('close flushes the logs buffer', async () => { vi.useRealTimers(); - const flushLogsSpy = vi.spyOn(logsInternalModule, '_INTERNAL_flushLogsBuffer').mockImplementation(() => undefined); + const flushLogsSpy = vi + .spyOn(logsInternalModule, '_INTERNAL_flushLogsBuffer') + .mockImplementation(() => undefined); const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options);