migrate-nango-deletion-detection
Migrating Nango Deletion Detection
Do this
- Find legacy usage:
deleteRecordsFromPreviousExecutions(trackDeletes:/track_deletes
- For each sync + model that needs automatic deletion detection:
- Add
await nango.trackDeletesStart('ModelName')at the start ofexec(before fetching/saving). - Replace
await nango.deleteRecordsFromPreviousExecutions('ModelName')withawait nango.trackDeletesEnd('ModelName'). - Keep
trackDeletesEndafter allbatchSave/batchUpdate/batchDeletecalls.
- Add
- Safety:
- Only call
trackDeletesEndif the full dataset was fetched + saved betweentrackDeletesStartandtrackDeletesEnd(otherwise you can cause false deletions). - Prefer letting exceptions bubble. If you
catch, re-throw when data is incomplete.
- Only call
Checkpointed full refresh (multi-execution)
- Call
trackDeletesStart('ModelName')at the beginning of each execution in the refresh window (it is safe/idempotent while the window is open). - Call
trackDeletesEnd('ModelName')only in the execution that finishes saving the full dataset.
Tests
- Re-record mocks after code changes:
nango dryrun <sync-name> <connection-id> --validate -e dev --no-interactive --auto-confirmnango dryrun <sync-name> <connection-id> --save -e dev --no-interactive --auto-confirmnango generate:tests && npm test
- Never hand-edit
*.test.json.
Before/after
// Before
for await (const page of nango.paginate(cfg)) {
await nango.batchSave(page, 'Ticket');
}
await nango.deleteRecordsFromPreviousExecutions('Ticket');
// After
await nango.trackDeletesStart('Ticket');
for await (const page of nango.paginate(cfg)) {
await nango.batchSave(page, 'Ticket');
}
await nango.trackDeletesEnd('Ticket');
More from nangohq/skills
nango-function-builder
Builds Nango Functions (TypeScript createAction/createSync) with checkpoint-first sync patterns, action and sync references, project/root checks, deletion strategies, and a docs-aligned dryrun/test workflow. Use when creating or updating Nango actions or syncs.
120building-nango-functions-locally
Builds Nango Functions in a checked-out Zero YAML TypeScript Nango project using local files, index.ts registration, nango dryrun, generated tests, and optional nango deploy. Use when creating or updating Nango actions or syncs locally.
76migrating-nango-deletion-detection
Migrates Nango syncs from deleteRecordsFromPreviousExecutions()/trackDeletes to trackDeletesStart/trackDeletesEnd for automated deletion detection (including checkpoint-based full refresh). Use when updating existing createSync code.
65building-nango-functions-remotely
Builds Nango Functions without a checked-out Nango project by calling Nango remote compile, dryrun, and deploy endpoints, resolving NANGO_SERVER_URL from env or .env, and using shared action and sync patterns. Use when creating or updating Nango actions or syncs remotely.
29migrating-to-zero-yaml
Manually migrates legacy `nango.yaml` Nango projects to Zero YAML TypeScript by generating `models.ts`, `index.ts`, package/tsconfig scaffolding, and wrapping legacy scripts in `createSync()`, `createAction()`, or `createOnEvent()`. Use when a Nango repo still has `nango.yaml` and needs manual Zero YAML migration.
28nango-toolbox
Universal gateway for any third-party API or SaaS (Google Calendar, Gmail, Slack, Notion, Linear, HubSpot, etc.). TRIGGER on any request to read or modify data in an external product, even when no matching MCP tool is loaded.
26