بنقرة واحدة
sync-debug
// Diagnose a failing or misbehaving sync — fetch run logs, identify errors, cross-reference with code, and suggest fixes
// Diagnose a failing or misbehaving sync — fetch run logs, identify errors, cross-reference with code, and suggest fixes
Scaffold a new sync capability with guided setup — asks about data source, mode, pagination, and cursor design, then generates working code
Guide to setting up third-party authentication for a Notion Worker. Covers external-service API keys / personal access tokens and OAuth. Use when the worker needs credentials for a non-Notion API, not for Notion API tokens or `ntn login`.
Comprehensive guide to building Notion Workers syncs — covers the two-sync architecture (backfill+delta), replace mode, pagination, consistency buffers, pacers, deletion strategies, and common pitfalls. Auto-loads when sync-related work is detected.
Review a sync capability for common bugs — cursor advancement, pagination termination, state persistence, bi-modal correctness, consistency buffers, and deletion handling
| name | sync-debug |
| description | Diagnose a failing or misbehaving sync — fetch run logs, identify errors, cross-reference with code, and suggest fixes |
| user-invocable | true |
| disable-model-invocation | true |
| allowed-tools | ["Read","Bash","Glob","Grep","Edit","Write"] |
Help the user figure out why their sync is failing or producing wrong results. Work through the steps below systematically.
Run these commands to understand the situation:
ntn workers sync status
Note which syncs are listed, their status, last run time, and next scheduled run. Look for syncs that are stuck, failing, or haven't run recently.
ntn workers runs list
Look for runs with non-zero exit codes (shown in red in table output). Note the run IDs for failed runs.
For the most recent run (any capability):
ntn workers runs list --plain | head -n1 | cut -f1 | xargs -I{} ntn workers runs logs {}
For the most recent run of a specific sync:
ntn workers runs list --plain | grep <syncKey> | head -n1 | cut -f1 | xargs -I{} ntn workers runs logs {}
Read the full log output. Look for error messages, stack traces, and any console.log output from the sync code.
Read src/index.ts (and any imported modules) to understand the sync's logic. Cross-reference the error from the logs with the code.
Common failure patterns and their fixes:
API Authentication Errors (401/403)
ntn workers oauth token <oauthKey>ntn workers env listntn workers env pushntn workers oauth start <key> to re-authenticateRate Limiting (429)
Timeout / Long Execution
Cursor / State Errors
ntn workers sync state reset <key> to clear state and re-backfill from scratchSchema Mismatch
changes don't match the schema.properties definitionproperties object of each change matches a key in the schemaBuilder.title() is used for Schema.title() properties, Builder.richText() for Schema.richText(), etc.Infinite Loop (sync never completes)
hasMore is always true — the cursor isn't advancingnextState changes between iterationsEmpty Results
Network / Transient Errors
ntn workers sync trigger <key>After identifying the issue:
npm run check to verify typesntn workers sync state reset <key> (this triggers a full re-backfill)/sync-preview or run ntn workers deploy && ntn workers sync trigger <key> --previewntn workers sync trigger <key> to resume