Save connector state
Persist cursors and progress safely across worker invocations without advancing past unfinished work.
This applies to stateful extraction and loading workers. See worker routing for initialization.
Connector state and persistence
adapter.state stores your connector's JSON data: pagination cursors, phase progress and idempotency intent. The SDK's state envelope and extraction boundaries are internal. Extraction and loading use separate state. A write to extraction state does not appear in a loading worker.
Stateful invocations load state before calling the task. initialState seeds missing state. Reinitialize phase-local progress when a genuinely new run begins and preserve it on continuation or replay within that run.
When a task returns a result, including status: 'error', the SDK flushes extraction repos, saves state and then emits that result. If the task throws or the flush fails, the SDK attempts an error callback with the output already uploaded and skips the automatic state save. An earlier explicit state write can still affect where replay resumes.
postState() saves immediately without flushing repos and throws on failure. In extraction, upload the records covered by a checkpoint before calling it. In loading, it can record write intent before an external mutation. Use source idempotency keys or read-after-write reconciliation if the outcome of the mutation is unclear. Large connector-owned datasets can use uploadArtifact/downloadArtifact; store only their references in state. Such uploads are not reported as extracted output.
Discovery and deletion are stateless. Do not use them for work that requires an SDK-persisted continuation cursor. See state deletion for cleanup limitations.
Related: Worker routing.
Last updated on