From 91d22fe98f3037c456da663452fdce4e53048e80 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 29 Jul 2025 11:34:06 -0700 Subject: [PATCH 1/4] fix: log reads despite errors --- .../runner/src/storage/transaction/journal.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/runner/src/storage/transaction/journal.ts b/packages/runner/src/storage/transaction/journal.ts index 447a8e890..19253887d 100644 --- a/packages/runner/src/storage/transaction/journal.ts +++ b/packages/runner/src/storage/transaction/journal.ts @@ -109,18 +109,19 @@ export const read = ( if (error) { return { error }; } else { + // Track read activity with metadata + journal.state.activity.push({ + read: { + ...address, + space, + meta: options?.meta ?? {}, + }, + }); + const result = branch.read(address, options); if (result.error) { return { error: result.error.from(space) }; } else { - // Track read activity with metadata - journal.state.activity.push({ - read: { - ...address, - space, - meta: options?.meta ?? {}, - }, - }); return result; } } From d9d68b85a0ec21d2b825d8bddd8855dffd5502c5 Mon Sep 17 00:00:00 2001 From: Bernhard Seefeld Date: Tue, 29 Jul 2025 14:35:43 -0500 Subject: [PATCH 2/4] only look for relevant reads (list now contains many more) --- packages/runner/test/schema.test.ts | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/runner/test/schema.test.ts b/packages/runner/test/schema.test.ts index 03869d200..368d3d218 100644 --- a/packages/runner/test/schema.test.ts +++ b/packages/runner/test/schema.test.ts @@ -370,15 +370,26 @@ describe("Schema Support", () => { }); const log = txToReactivityLog(tx); const reads = sortAndCompactPaths(log.reads); - expect(reads.length).toEqual(3); - expect( - reads.map((r: IMemorySpaceAddress) => ({ id: r.id, path: r.path })) - .sort((a, b) => a.id.localeCompare(b.id)), - ).toEqual([ - { id: toURI(docCell.entityId!), path: ["current"] }, - { id: toURI(linkEntityId), path: [] }, - { id: toURI(initialEntityId), path: ["foo"] }, - ].sort((a, b) => a.id.localeCompare(b.id))); + console.log(reads); + expect(reads.length).toEqual(9); + expect(reads).toContainEqual({ + space, + id: toURI(linkEntityId), + path: [], + type: "application/json", + }); + expect(reads).toContainEqual({ + space, + id: toURI(docCell.entityId!), + path: ["current"], + type: "application/json", + }); + expect(reads).toContainEqual({ + space, + id: toURI(initialEntityId), + path: ["foo"], + type: "application/json", + }); // Then update it initial.withTx(tx).set({ foo: { label: "first - update" } }); @@ -405,7 +416,7 @@ describe("Schema Support", () => { await runtime.idle(); - (expect(rootValues) as any).toEqualIgnoringSymbols([ + expect(rootValues).toEqual([ "root", "cancelled", "root", @@ -418,7 +429,7 @@ describe("Schema Support", () => { await runtime.idle(); - (expect(rootValues) as any).toEqualIgnoringSymbols([ + expect(rootValues).toEqual([ "root", "cancelled", "root", From 023729a04143fd478fe54c7ccbd6bfd55a3f4c01 Mon Sep 17 00:00:00 2001 From: Bernhard Seefeld Date: Tue, 29 Jul 2025 14:36:05 -0500 Subject: [PATCH 3/4] fix traversing over shortened paths to objects --- packages/runner/src/reactive-dependencies.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/runner/src/reactive-dependencies.ts b/packages/runner/src/reactive-dependencies.ts index 5a1443f32..e5c773ac3 100644 --- a/packages/runner/src/reactive-dependencies.ts +++ b/packages/runner/src/reactive-dependencies.ts @@ -150,10 +150,12 @@ export function determineTriggeredActions( if (i <= beforeLastObject) { beforeValues[i + 1] = (beforeValues[i] as Keyable)[targetPath[i]!]; if (isRecord(beforeValues[i + 1])) beforeLastObject = i + 1; + else beforeLastObject = i; } if (i <= afterLastObject) { afterValues[i + 1] = (afterValues[i] as Keyable)[targetPath[i]!]; if (isRecord(afterValues[i + 1])) afterLastObject = i + 1; + else afterLastObject = i; } } currentPath = targetPath; From 63f31ac1e0dd60c4a43ce53178ec546770ba9095 Mon Sep 17 00:00:00 2001 From: Bernhard Seefeld Date: Tue, 29 Jul 2025 14:49:38 -0500 Subject: [PATCH 4/4] fix test for shim flow --- packages/runner/test/schema.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/runner/test/schema.test.ts b/packages/runner/test/schema.test.ts index 368d3d218..9825faaf5 100644 --- a/packages/runner/test/schema.test.ts +++ b/packages/runner/test/schema.test.ts @@ -371,7 +371,6 @@ describe("Schema Support", () => { const log = txToReactivityLog(tx); const reads = sortAndCompactPaths(log.reads); console.log(reads); - expect(reads.length).toEqual(9); expect(reads).toContainEqual({ space, id: toURI(linkEntityId),