Skip to content

Commit 3ed4a5b

Browse files
committed
fix(client): retain storage generation in HTTP thread snapshots
1 parent fc9a943 commit 3ed4a5b

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎packages/client-runtime/src/state/boundedThreadSnapshotHttp.test.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const BoundedJson = Schema.toCodecJson(OrchestrationV2ThreadBoundedSnapshot);
127127
const idTableBody = () => {
128128
const decodeBoundedJson = Schema.decodeSync(BoundedJson);
129129

130-
const snapshot = decodeBoundedJson(boundedBody(true));
130+
const snapshot = decodeBoundedJson({ ...boundedBody(true), storageGeneration: "durable" });
131131
const encodeBoundedJson = Schema.encodeSync(BoundedJson);
132132

133133
return encodeBoundedJson({ ...snapshot, idTable: true });
@@ -185,10 +185,14 @@ describe("boundedThreadSnapshotLoader", () => {
185185
);
186186

187187
it.effect.each([
188-
["an older server that ignores the opt-in", () => boundedBody(false)],
189-
["a server that sends compact turnItems", () => boundedBody(true)],
190-
["a server that also sends an ID table", idTableBody],
191-
] as const)("requests compact turnItems and loads %s", ([, body]) => {
188+
["an older server that ignores the opt-in", () => boundedBody(false), undefined],
189+
[
190+
"a server that sends compact turnItems",
191+
() => ({ ...boundedBody(true), storageGeneration: "durable" }),
192+
"durable",
193+
],
194+
["a server that also sends an ID table", idTableBody, "durable"],
195+
] as const)("requests compact turnItems and loads %s", ([, body, storageGeneration]) => {
192196
const urls: string[] = [];
193197
const fetchFn = ((input: RequestInfo | URL) => {
194198
urls.push(String(input));
@@ -202,6 +206,7 @@ describe("boundedThreadSnapshotLoader", () => {
202206
expect(new URL(urls[0]!).searchParams.get("compactIds")).toBe("1");
203207
expect(result._tag).toBe("present");
204208
if (result._tag !== "present") return;
209+
expect(result.snapshot.storageGeneration).toBe(storageGeneration);
205210
expect(result.snapshot.projection.turnItems.map((item) => String(item.id))).toEqual([
206211
"local-1",
207212
"local-2",

‎packages/client-runtime/src/state/boundedThreadSnapshotHttp.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export const layer: Layer.Layer<
9090
_tag: "present",
9191
snapshot: {
9292
snapshotSequence: bounded.snapshotSequence,
93+
...(bounded.storageGeneration === undefined
94+
? {}
95+
: { storageGeneration: bounded.storageGeneration }),
9396
projection: bounded.projection,
9497
latestLocalTurnOrdinal: bounded.latestLocalTurnOrdinal,
9598
},

0 commit comments

Comments
 (0)