Skip to content

refactor: migrate ClientSessionSyncProcessor’s materializeEvent() to Effect #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: igor/refactor-client-session-sync-processor-push-to-effect
Choose a base branch
from

Conversation

IGassmann
Copy link
Collaborator

@IGassmann IGassmann commented Jun 13, 2025

This migrates ClientSessionSyncProcessor’s materializeEvent() to Effect to make it easier to instrument it with OpenTelemetry.

Caution

DO NOT MERGE!

This is a stacked PR. To preserve logical order, and a clean commit history, these must be merged from the bottom upwards. I'll handle the merges and rebases myself, as it can be tricky to do properly.

Merge order:

  1. refactor: migrate ClientSessionSyncProcessor.push() to Effect #375 (base)
  2. refactor: migrate ClientSessionSyncProcessor’s materializeEvent() to Effect #376
  3. refactor: migrate store.commit to Effect #381 (top)

Checklist

  • I grant to recipients of this Project distribution a perpetual,
    non-exclusive, royalty-free, irrevocable copyright license to reproduce, prepare
    derivative works of, publicly display, sublicense, and distribute this
    Contribution and such derivative works.
  • I certify that I am legally entitled to grant this license, and that this
    Contribution contains no content requiring a license from any third party.

Sorry, something went wrong.

@CLAassistant
Copy link

CLAassistant commented Jun 13, 2025

CLA assistant check
All committers have signed the CLA.

@IGassmann IGassmann requested a review from Copilot June 13, 2025 14:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the ClientSessionSyncProcessor’s materializeEvent implementation to use Effect for improved instrumentability with OpenTelemetry. Key changes include:

  • Updating snapshot files to include a new children field for materialize-event.
  • Refactoring materializeEvent in store.ts to use Effect.fn and Effect.gen.
  • Updating ClientSessionSyncProcessor to yield* the new materializeEvent effect.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/@livestore/react/src/snapshots/useClientDocument.test.tsx.snap Updated snapshots with the new children property for materialize-event.
packages/@livestore/livestore/src/store/store.ts Transformed materializeEvent to use Effect, with changes to error handling and asynchronous behavior.
packages/@livestore/livestore/src/live-queries/snapshots/db-query.test.ts.snap Updated snapshots to include new children for materialize-event.
packages/@livestore/common/src/sync/ClientSessionSyncProcessor.ts Adjusted the materializeEvent signature and added yield* calls to invoke the new effect.
Comments suppressed due to low confidence (1)

packages/@livestore/livestore/src/store/store.ts:155

  • Consider wrapping the sqliteDbWrapper.cachedExecute call within a try-catch block inside the Effect.sync callback to preserve the error context from the previous implementation. If relying solely on the effect's error channel, ensure that the absence of a custom error wrapper does not impact debugging or error tracing.
this.sqliteDbWrapper.cachedExecute(statementSql, bindValues, { otelContext, writeTables })

@IGassmann IGassmann requested a review from schickling June 13, 2025 14:28
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from a2bc64d to ad77fc1 Compare June 17, 2025 09:35
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 1bcfa59 to 2a6b1ad Compare June 17, 2025 09:35
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from ad77fc1 to 6e169e9 Compare July 8, 2025 07:59
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 05a562b to d9cee66 Compare July 8, 2025 07:59
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 6e169e9 to feb4b6b Compare July 8, 2025 08:04
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 3 times, most recently from 1ec08dd to 93f3115 Compare July 8, 2025 08:15
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 9fff208 to 3512305 Compare July 8, 2025 08:59
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 93f3115 to 3e014c0 Compare July 8, 2025 09:00
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 3512305 to 42459d2 Compare July 8, 2025 09:00
@IGassmann IGassmann marked this pull request as draft July 8, 2025 09:25
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 42459d2 to a607146 Compare July 8, 2025 09:25
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 3e014c0 to 4ee1579 Compare July 8, 2025 09:25
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from a607146 to a65a1b7 Compare July 8, 2025 09:34
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 4ee1579 to 543308e Compare July 8, 2025 09:34
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 1690716 to ec08957 Compare July 8, 2025 09:56
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 2 times, most recently from 0eddddb to 0defe0e Compare July 8, 2025 10:07
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch 2 times, most recently from 38c991b to 4978123 Compare July 8, 2025 10:17
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 2 times, most recently from 02a30c8 to e42880f Compare July 8, 2025 10:24
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 4978123 to 8b36600 Compare July 8, 2025 12:14
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 2 times, most recently from d5f5100 to 3a2f28a Compare July 8, 2025 12:17
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 5 times, most recently from 8d07a4b to 462bd0c Compare July 8, 2025 12:33
@IGassmann IGassmann marked this pull request as ready for review July 8, 2025 12:49
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 2f1778d to 1037dfd Compare July 8, 2025 13:20
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from 462bd0c to c6e6198 Compare July 8, 2025 13:20
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 1037dfd to feac3a1 Compare July 9, 2025 10:56
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from feac3a1 to 7bd8205 Compare July 29, 2025 07:30
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from c6e6198 to 20d0e77 Compare July 29, 2025 07:33
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 7bd8205 to 75c4aa0 Compare July 29, 2025 07:37
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 2 times, most recently from 256ec88 to 67064d4 Compare July 29, 2025 07:38
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-push-to-effect branch from 75c4aa0 to 1c517d0 Compare July 29, 2025 08:14
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 6 times, most recently from c350558 to 29d458c Compare July 29, 2025 10:21
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch 2 times, most recently from daeb6f0 to d6321b3 Compare July 30, 2025 14:38

Verified

This commit was signed with the committer’s verified signature.
hbhalodia Hit Bhalodia
…nc-processor:materialize-event" span
@IGassmann IGassmann force-pushed the igor/refactor-client-session-sync-processor-materializeevent-to-effect branch from d6321b3 to 9644d7c Compare July 31, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants