Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Jul 29, 2025

Add synced() method to wait for all pending syncs and commits to complete:

  • Add synced() to IStorageManager and IStorageProvider interfaces
  • Track commit promises in Replica to await pending transactions
  • Implement synced() in Provider to wait for both subscriptions and commits
  • Add getAllPromises() to SelectorTracker for subscription tracking
  • Update Storage.synced() to use new implementation when not in shim mode

This ensures all pending operations complete before synced() resolves, including both document syncs and transaction commits.


Summary by cubic

Added a synced() method to the storage system to ensure all pending syncs and transaction commits finish before continuing.

  • New Features
    • Added synced() to IStorageManager and IStorageProvider interfaces.
    • synched() now waits for both document syncs and in-flight transaction commits.
    • Updated internal tracking to support awaiting all relevant promises.

@seefeldb seefeldb requested review from Copilot and ubik2 July 29, 2025 15:04
@linear
Copy link

linear bot commented Jul 29, 2025

Copy link
Contributor

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 implements the synced() method across the storage system to properly wait for all pending synchronization and commit operations to complete in the new transaction system.

  • Add synced() method to storage interfaces and implementations
  • Track commit promises in Replica to enable awaiting pending transactions
  • Implement comprehensive sync waiting that covers both document syncs and transaction commits

Reviewed Changes

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

File Description
packages/runner/src/storage/interface.ts Add synced() method signatures to IStorageManager and IStorageProvider interfaces
packages/runner/src/storage/cache.ts Implement synced() functionality, track commit promises, and add getAllPromises() helper
packages/runner/src/storage.ts Update Storage.synced() to use new implementation when not in shim mode

Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The type assertion as unknown as Promise<void> is unsafe and obscures the actual return type. Consider using void in the Promise.all() call or explicitly handling the array result.

Suggested change
]) as unknown as Promise<void>;
]).then(() => {});

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

No issues found across 3 files. Review in cubic

seefeldb added 2 commits July 29, 2025 10:10
Add synced() method to wait for all pending syncs and commits to complete:
- Add synced() to IStorageManager and IStorageProvider interfaces
- Track commit promises in Replica to await pending transactions
- Implement synced() in Provider to wait for both subscriptions and commits
- Add getAllPromises() to SelectorTracker for subscription tracking
- Update Storage.synced() to use new implementation when not in shim mode

This ensures all pending operations complete before synced() resolves, including
both document syncs and transaction commits.
@seefeldb seefeldb force-pushed the berni/ct-666-implement-await-storagesynced-for-new-tx-system branch from 2fc5ea6 to 68cb124 Compare July 29, 2025 15:10
@seefeldb seefeldb merged commit 782da23 into main Jul 29, 2025
8 checks passed
@seefeldb seefeldb deleted the berni/ct-666-implement-await-storagesynced-for-new-tx-system branch July 29, 2025 15:23
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.

2 participants