diff --git a/src/channels/draft-stream-loop.test.ts b/src/channels/draft-stream-loop.test.ts index ac613c35398e..1e043710a597 100644 --- a/src/channels/draft-stream-loop.test.ts +++ b/src/channels/draft-stream-loop.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; import { createDraftStreamLoop } from "./draft-stream-loop.js"; @@ -29,6 +29,14 @@ async function captureUnhandledRejections( } describe("createDraftStreamLoop", () => { + beforeEach(() => { + vi.useRealTimers(); + }); + + afterEach(() => { + vi.useRealTimers(); + }); + it("contains immediate background flush rejections and preserves pending text", async () => { await captureUnhandledRejections(async (rejections) => { const error = new Error("send failed"); diff --git a/src/channels/typing-lifecycle.ts b/src/channels/typing-lifecycle.ts index 20b7bdd97389..d73630b9b5e9 100644 --- a/src/channels/typing-lifecycle.ts +++ b/src/channels/typing-lifecycle.ts @@ -33,6 +33,7 @@ export function createTypingKeepaliveLoop(params: { timer = setInterval(() => { void tick(); }, params.intervalMs); + timer.unref?.(); }; const stop = () => { diff --git a/src/channels/typing.ts b/src/channels/typing.ts index 0d6ac7c3e872..4ca7aff5d2fa 100644 --- a/src/channels/typing.ts +++ b/src/channels/typing.ts @@ -76,6 +76,7 @@ export function createTypingCallbacks(params: CreateTypingCallbacksParams): Typi fireStop(); } }, maxDurationMs); + ttlTimer.unref?.(); }; const clearTtlTimer = () => {