mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-10 15:45:59 +01:00
Previously, we fetched the initial state *before* registering the new subscription. Any events emitted after the DB read but before the subscription was installed were dropped—most visible under low-resource conditions (e.g., CI). Change: - Register the subscription first, then asynchronously fetch and send the initial state (spawned task). This eliminates the window where events could be missed. - Require `F: Send + Sync` and store `on_new_subscription` as `Arc<F>` so it can be safely used from the spawned task. Result: - No gap between “subscribe” and “start receiving,” avoiding lost events. - Initial state still delivered, now via a background task.