supermemoryai/supermemory · error · Error
Supermemory API request failed: ${error}
Error message
Supermemory API request failed: ${error} What it means
A catch-all in supermemoryProfileSearch that re-throws non-Error throwables (strings, plain objects, DOMExceptions from AbortSignal timeouts) wrapped as Error so callers always get an Error with a stack. The original value is preserved in the message.
Source
Thrown at packages/tools/src/openai/middleware.ts:131
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: payload,
})
if (!response.ok) {
const errorText = await response.text().catch(() => "Unknown error")
throw new Error(
`Supermemory profile search failed: ${response.status} ${response.statusText}. ${errorText}`,
)
}
return await response.json()
} catch (error) {
if (error instanceof Error) {
throw error
}
throw new Error(`Supermemory API request failed: ${error}`)
}
}
/**
* Adds memory-enhanced system prompts to chat completion messages.
*
* Searches for relevant memories based on the specified mode and injects them
* into the conversation. If a system prompt already exists, memories are appended
* to it. Otherwise, a new system prompt is created with the memories.
*
* @param messages - Array of chat completion message parameters
* @param containerTag - The container tag/identifier for memory search
* @param logger - Logger instance for debugging and info output
* @param mode - Memory search mode: "profile" (all memories), "query" (search-based), or "full" (both)
* @param baseUrl - The Supermemory API base URL
* @param apiKey - The Supermemory API key used to authenticate the request
* @returns Promise that resolves to enhanced messages with memory-injected system prompt
*View on GitHub (pinned to d436792e77)
Solutions
- Inspect the wrapped message to find the real rejection cause
- Handle abort/timeout cases explicitly and retry or degrade
- Upgrade the runtime/polyfill so fetch rejections are standard Errors
Example fix
// before
await supermemoryProfileSearch(payload)
// after
try {
await supermemoryProfileSearch(payload)
} catch (e) {
if (e instanceof Error && /abort/i.test(e.message)) return fallback()
throw e
} Defensive patterns
Strategy: try-catch
Try / catch
try { await supermemoryProfileSearch(p) } catch (e) { if (e instanceof Error && /abort|timeout/i.test(e.message)) return fallback; throw e } Prevention
- Set explicit AbortSignals and handle aborts as a distinct case
- Log the wrapped message verbatim to preserve the original rejection cause
When it happens
Trigger: fetch rejecting with an AbortError/timeout DOMException that is not an Error instance in the runtime, or custom fetch implementations rejecting with plain objects.
Common situations: Request aborted via AbortSignal.timeout (FETCH_TIMEOUT_MS) in edge/serverless runtimes; quirky fetch polyfills rejecting with strings.
Related errors
- Supermemory API request failed: ${error}
- Failed to add conversation: ${response.status} ${response.st
- withSupermemory: options must be an object with required con
- containerTag is required — provide a non-empty string to ide
- customId is required — provide a non-empty string to group m
AI-assisted analysis of supermemoryai/supermemory@d436792e77 (2026-08-28).
Data as JSON: /api/errors/5949034f278d7db5.
Report an issue: GitHub.