Merge branch 'main' into feat/n8n-nodes-mem0

This commit is contained in:
Kartik
2026-07-29 21:42:42 +05:30
committed by GitHub
3 changed files with 22 additions and 3 deletions
@@ -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(