Skip to content

fix(mcp): drop unreachable throw in setTimeout-wrapped initial sync#318

Merged
zc277584121 merged 1 commit into
zilliztech:masterfrom
mvanhorn:fix/256-settimeout-error-swallow
Apr 24, 2026
Merged

fix(mcp): drop unreachable throw in setTimeout-wrapped initial sync#318
zc277584121 merged 1 commit into
zilliztech:masterfrom
mvanhorn:fix/256-settimeout-error-swallow

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Drops a throw error inside the initial-sync setTimeout callback in packages/mcp/src/sync.ts. The callback runs with no caller, so the throw has nowhere to propagate. The preceding console.error(...) is the terminal signal for unexpected failures.

Why this matters

Reporter in #256 called out the bug with an exact file:line pointer. Unexpected errors during the 5s-deferred initial sync are silently lost today, not surfaced. This is a pure log-and-continue fix.

Changes

                 } else {
                     console.error('[SYNC-DEBUG] Initial sync failed with unexpected error:', error);
-                    throw error;
+                    // Do not re-throw here: this callback runs via setTimeout with no caller to propagate to.
                 }

No other changes. No behavior regression: the throw was already unreachable.

Testing

pnpm install --frozen-lockfile && pnpm build passes locally on Node 22.

Related sync.ts PRs

Aware of #314, #274, #268, #234 also touching packages/mcp/src/sync.ts. None of them address the setTimeout throw (#314 preserves it at the relocated line). Whichever lands first, the other rebases cleanly.

Fixes #256

The throw inside an async setTimeout callback has no caller to propagate
to, so unexpected errors during the 5s-deferred initial sync are silently
lost anyway. The preceding console.error already covers observability.

Fixes zilliztech#256
@zc277584121 zc277584121 merged commit b7755c3 into zilliztech:master Apr 24, 2026
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Appreciate getting the dead-code path out of the initial sync.

lufftw pushed a commit to lufftw/claude-context that referenced this pull request May 8, 2026
…illiztech#318)

Remove throw in setTimeout callback that would crash the MCP server process on unexpected background sync errors. The error is already logged via console.error, and the periodic sync will retry on the next cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error thrown inside setTimeout goes nowhere

2 participants