This commit is contained in:
pawan 2026-08-27 15:42:47 +05:30 committed by GitHub
commit cc82ab765c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View file

@ -33,7 +33,12 @@ export async function forgetMemoryRequest(
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify(params),
signal: options?.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS),
// compose the caller's signal with the timeout instead of choosing
// between them: `??` dropped the 30s bound whenever a signal was passed,
// which reopened the unbounded-request hang that #1451 closed.
signal: options?.signal
? AbortSignal.any([options.signal, AbortSignal.timeout(FETCH_TIMEOUT_MS)])
: AbortSignal.timeout(FETCH_TIMEOUT_MS),
})
if (!response.ok) {

View file

@ -112,7 +112,7 @@ describe("memoryForget", () => {
expect(init.signal).toBeInstanceOf(AbortSignal)
})
it("uses a caller-provided signal instead of creating a timeout", async () => {
it("composes the caller signal with the timeout so both still bound the request", async () => {
const fetchMock = stubFetch()
const controller = new AbortController()
@ -124,7 +124,15 @@ describe("memoryForget", () => {
)
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit]
expect(init.signal).toBe(controller.signal)
const signal = init.signal as AbortSignal
// #1549: a composed signal, not the raw caller signal. the 30s timeout
// must not be dropped just because a caller passes their own signal.
expect(signal).toBeInstanceOf(AbortSignal)
expect(signal).not.toBe(controller.signal)
expect(signal.aborted).toBe(false)
// the caller's signal still aborts the request through the composite
controller.abort()
expect(signal.aborted).toBe(true)
})
it("throws a descriptive error on non-2xx responses", async () => {