mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Merge b202862ea4 into f11d8c4620
This commit is contained in:
commit
cc82ab765c
2 changed files with 16 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue