@statesync/core / SyncErrorContext
Interface: SyncErrorContext
Defined in: types.ts:273
Structured error context passed to the RevisionSyncOptions.onError callback.
Contains enough information for error handlers to log, alert, or build dashboards around sync failures. All fields beyond phase and error are optional and populated on a best-effort basis.
Example
function handleSyncError(ctx: SyncErrorContext) {
if (ctx.phase === 'getSnapshot' && ctx.willRetry) {
console.warn(`Retry attempt ${ctx.attempt}, next in ${ctx.nextDelayMs}ms`);
} else {
reportToSentry(ctx.error, { phase: ctx.phase, topic: ctx.topic });
}
}Properties
attempt?
optional attempt: number;Defined in: types.ts:304
The current retry attempt number (1-based). Present when the error is reported by the retry wrapper.
error
error: unknown;Defined in: types.ts:279
The error value. May be an Error instance or any thrown value.
eventRevision?
optional eventRevision: Revision;Defined in: types.ts:293
The revision from the invalidation event that triggered the refresh, if applicable.
localRevision?
optional localRevision: Revision;Defined in: types.ts:289
The local revision at the time of the error. Helpful for triage and metrics.
nextDelayMs?
optional nextDelayMs: number;Defined in: types.ts:313
The delay in milliseconds before the next retry attempt. Present when willRetry is true.
phase
phase: SyncPhase;Defined in: types.ts:275
The sync lifecycle phase where the error occurred.
snapshotRevision?
optional snapshotRevision: Revision;Defined in: types.ts:297
The revision from the snapshot that was being processed when the error occurred.
sourceEvent?
optional sourceEvent: unknown;Defined in: types.ts:284
Raw event payload when applicable (transport-specific). Intentionally unknown to keep core transport-agnostic.
sourceId?
optional sourceId: string;Defined in: types.ts:299
The source identifier from the invalidation event, if available.
topic?
optional topic: string;Defined in: types.ts:277
The topic associated with this sync loop, if available.
willRetry?
optional willRetry: boolean;Defined in: types.ts:308
Whether the engine or retry wrapper will attempt another try after this error.
