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

Method fetchChanges

packages/rpc/src/server.ts:165–192  ·  view source on GitHub ↗
(input: { after?: ChangeCursor; ignore?: string[] })

Source from the content-addressed store, hash-verified

163 }
164
165 async fetchChanges(input: { after?: ChangeCursor; ignore?: string[] }): Promise<{
166 currentCursor: ChangeCursor;
167 appliedPushCursor: ChangeCursor;
168 stream: ReadableStream<ChangeEntry>;
169 }> {
170 if (this.options.beforeFetch !== undefined) {
171 try {
172 await this.options.beforeFetch();
173 } catch (err) {
174 // Settle hook failures must not surface as fetch failures —
175 // we still want to stream whatever's already in the store.
176 // Log so the operator notices a wedged shim, then carry on.
177 console.warn("[SyncRPCServer] beforeFetch hook failed:", err);
178 }
179 }
180 const after = input.after ?? { rev: 0, path: null };
181 const ignore =
182 input.ignore ?? (this.options.ignore.length > 0 ? this.options.ignore : DEFAULT_IGNORE);
183 const snapshotRev = currentRev(this.db);
184 const currentCursor = { rev: snapshotRev, path: null };
185 return {
186 currentCursor,
187 appliedPushCursor: readFetchCursor(this.db),
188 stream: iterableToReadableStream(
189 coalesceChanges(this.db, after, { ignore, through: currentCursor }),
190 ),
191 };
192 }
193
194 async readEntry(path: string): Promise<ChangeEntry | null> {
195 return materialiseChange(this.db, path);

Callers

nothing calls this directly

Calls 5

currentRevFunction · 0.90
readFetchCursorFunction · 0.90
coalesceChangesFunction · 0.90
iterableToReadableStreamFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected