MCPcopy Create free account
hub / github.com/cloudflare/computer / startSyncLoop

Function startSyncLoop

packages/computerd/src/fuse/vfs.ts:127–143  ·  view source on GitHub ↗
(db: Database, upstream: SyncRPC)

Source from the content-addressed store, hash-verified

125// kill the daemon. The watermarks are durable, so the next tick
126// resumes from where the failed one would have.
127function startSyncLoop(db: Database, upstream: SyncRPC): () => void {
128 let stopped = false;
129 const handle = setInterval(() => {
130 if (stopped) return;
131 tick(db, upstream).catch((error) => {
132 console.error("sync tick failed:", error);
133 });
134 }, SYNC_TICK_MS);
135 // Don't block process exit on the timer. computerd's shutdown path
136 // calls stopSync() explicitly; this is belt-and-braces.
137 handle.unref?.();
138 return () => {
139 if (stopped) return;
140 stopped = true;
141 clearInterval(handle);
142 };
143}

Callers 1

Calls 2

tickFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected