The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
fix(vector-stores): prevent unhandled promise rejection in Supabase & Redis constructors (#6111)
Kartik2bd3ff1eff52
diff --git a/mem0-ts/src/oss/src/vector_stores/redis.ts b/mem0-ts/src/oss/src/vector_stores/redis.tsindex deae5e3ac..5b72e53b5 100644--- a/mem0-ts/src/oss/src/vector_stores/redis.ts+++ b/mem0-ts/src/oss/src/vector_stores/redis.ts@@ -197,7 +197,6 @@ export class RedisDB implements VectorStore {this.initialize().catch((err) => {console.error("Failed to initialize Redis:", err);- throw err;});}diff --git a/mem0-ts/src/oss/src/vector_stores/supabase.ts b/mem0-ts/src/oss/src/vector_stores/supabase.tsindex 3e357c575..748fe8283 100644--- a/mem0-ts/src/oss/src/vector_stores/supabase.ts+++ b/mem0-ts/src/oss/src/vector_stores/supabase.ts@@ -96,7 +96,6 @@ export class SupabaseDB implements VectorStore {this.initialize().catch((err) => {console.error("Failed to initialize Supabase:", err);- throw err;});}diff --git a/mem0-ts/src/oss/tests/vector-stores-compat.test.ts b/mem0-ts/src/oss/tests/vector-stores-compat.test.tsindex a9ecda1b1..81c9c7f34 100644--- a/mem0-ts/src/oss/tests/vector-stores-compat.test.ts+++ b/mem0-ts/src/oss/tests/vector-stores-compat.test.ts@@ -600,6 +600,45 @@ describe("Supabase – backward compat with mocked client", () => {await Promise.all([p1, p2]);// No crash = idempotent (Supabase init runs test insert only once)});++ it("constructor does not emit an unhandled rejection when init fails", async () => {+ jest.resetModules();+ jest.doMock("@supabase/supabase-js", () => {+ const failing = {+ from: jest.fn().mockReturnValue({+ insert: jest.fn().mockReturnValue({+ select: jest.fn().mockResolvedValue({+ error: { code: "42P01", message: "no table" },+ }),+ }),+ delete: jest.fn().mockReturnValue({+ eq: jest.fn().mockResolvedValue({ error: null }),+ }),+ }),+ };+ return { createClient: jest.fn().mockReturnValue(failing) };+ });+ const FailingSupabaseDB =+ require("../src/vector_stores/supabase").SupabaseDB;++ const rejections: unknown[] = [];+ const onUnhandled = (reason: unknown) => rejections.push(reason);+ process.on("unhandledRejection", onUnhandled);+ try {+ const store = new FailingSupabaseDB({+ supabaseUrl: "https://example.supabase.co",+ supabaseKey: "fake-key",+ tableName: "memories",+ collectionName: "test",+ });+ expect(store).toBeDefined();+ await new Promise((resolve) => setTimeout(resolve, 25));+ } finally {+ process.removeListener("unhandledRejection", onUnhandled);+ }++ expect(rejections).toEqual([]);+ });});// ───────────────────────────────────────────────────────────────────────────