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

  1. Inspect the wrapped message to find the real rejection cause
  2. Handle abort/timeout cases explicitly and retry or degrade
  3. 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

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


AI-assisted analysis of supermemoryai/supermemory@d436792e77 (2026-08-28). Data as JSON: /api/errors/5949034f278d7db5. Report an issue: GitHub.