@devries-cameron20 / composio-1 / commits / cf4232804
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(telemetry): clear timeout on serialization errors

jkomyno committed Aug 27, 2026 at 18:23 UTC cf4232804015621efb5327fe6100192733f6b4ad
2 files changed +25 -9
ts/packages/core/src/services/telemetry/TelemetryService.ts
+13 -9
@@ -14,17 +14,21 @@ export class TelemetryService {
14 * workerd pins the request context open for the full timeout on every successful
15 * send. Mirrors the bound applied to the npm version check.
16 */
17 - private static postWithTimeout(url: string, payload: unknown) {
17 + private static async postWithTimeout(url: string, payload: unknown) {
18 const controller = new AbortController();
19 const timer = setTimeout(() => controller.abort(), TELEMETRY_TIMEOUT_MS);
20 - return fetch(url, {
21 - method: 'POST',
22 - headers: {
23 - 'Content-Type': 'application/json',
24 - },
25 - body: JSON.stringify(payload),
26 - signal: controller.signal,
27 - }).finally(() => clearTimeout(timer));
20 + try {
21 + return await fetch(url, {
22 + method: 'POST',
23 + headers: {
24 + 'Content-Type': 'application/json',
25 + },
26 + body: JSON.stringify(payload),
27 + signal: controller.signal,
28 + });
29 + } finally {
30 + clearTimeout(timer);
31 + }
32 }
33
34 /**
ts/packages/core/test/telemetry/TelemetryService.test.ts
+12
@@ -460,6 +460,18 @@ describe('TelemetryService network bounding', () => {
460 expect(vi.getTimerCount()).toBe(0);
461 });
462
463 + it('clears the timer when serializing the payload fails', async () => {
464 + vi.useFakeTimers();
465 + const fetchMock = vi.fn<typeof fetch>();
466 + vi.stubGlobal('fetch', fetchMock);
467 +
468 + const payload = createPayload({ props: { value: BigInt(1) } });
469 +
470 + await expect(TelemetryService.sendMetric([payload])).resolves.toBeUndefined();
471 + expect(fetchMock).not.toHaveBeenCalled();
472 + expect(vi.getTimerCount()).toBe(0);
473 + });
474 +
475 it('swallows a sendMetric timeout when the endpoint never responds', async () => {
476 vi.useFakeTimers();
477 const fetchMock = vi.fn<typeof fetch>(