fix(zapier): raise the add_memory poll budget past the real API latency tail (#6680)

This commit is contained in:
Kartik
2026-07-29 21:32:22 +05:30
committed by GitHub
parent e168d48e04
commit 1ac3aa7256
3 changed files with 22 additions and 3 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ This is a **polyglot monorepo** containing Python and TypeScript packages, CLIs,
| `integrations/openclaw/` | `@mem0/openclaw-mem0` — OpenClaw plugin for Claude Code / AI editors |
| `integrations/pi-agent-plugin/` | `@mem0/pi-agent-plugin` — Pi Agent plugin |
| `integrations/vercel-ai-sdk/` | `@mem0/vercel-ai-provider` — Vercel AI SDK memory provider |
| `integrations/zapier-mem0/` | `zapier-mem0` — Zapier Platform CLI app (deploys to Zapier, not npm); add / search / get / delete memories |
| `integrations/zapier-mem0/` | `@mem0/zapier` — Zapier Platform CLI app (deploys to Zapier, not npm); add / search / get / delete memories |
| `server/` | FastAPI REST server for self-hosted Mem0 (Docker: FastAPI + PostgreSQL/pgvector + Neo4j) |
| `skills/` | Claude Code skill definitions. Reference skills (SDK knowledge, always-on): `mem0/`, `mem0-cli/`, `mem0-vercel-ai-sdk/`. Pipeline skills (run on demand): `mem0-integrate/`, `mem0-test-integration/`, `mem0-oss-to-platform/` |
| `docs/` | Documentation site (Mintlify) |
@@ -2,8 +2,8 @@ import type { ZObject, Bundle, AddResponse, EventResponse } from '../types';
import { captureEvent } from '../telemetry';
const POLL_INTERVAL_MS = 1500;
// Bounded so the poll budget stays under Zapier's per-step execution timeout.
const MAX_POLL_ATTEMPTS = 12;
// Bounded to a 60s poll budget, under Zapier's per-step execution timeout.
const MAX_POLL_ATTEMPTS = 40;
// Polls GET /v1/event/{id}/ until the async memory-addition event resolves.
const pollEvent = async (z: ZObject, eventId: string): Promise<EventResponse> => {
@@ -58,6 +58,25 @@ describe('add_memory (offline)', () => {
expect((res as any).status).toBe('SUCCEEDED');
});
it('keeps polling past the old 12-attempt budget when the API is slow', async () => {
jest.useFakeTimers();
const pendingPolls = Array.from({ length: 20 }, () => ({ data: { status: 'PENDING' } }));
const z = makeZ([
{ data: { event_id: 'e1', status: 'PENDING' } },
...pendingPolls,
{ data: { status: 'SUCCEEDED', results: [{ id: 'm1' }] } },
]);
const resultPromise = addMemory.operation.perform(z, {
inputData: { content: 'hi', user_id: 'u1', waitForCompletion: 'true' },
} as any);
for (let i = 0; i < pendingPolls.length; i++) {
await jest.advanceTimersByTimeAsync(1500);
}
const res = await resultPromise;
expect((res as any).status).toBe('SUCCEEDED');
jest.useRealTimers();
});
it('throws a clear error on invalid JSON metadata', async () => {
const z = makeZ();
await expect(