Skip to content

Commit

Permalink
[ENG-8227] fix test_new_sync_query_after_disconnect (#33104)
Browse files Browse the repository at this point in the history
test was failing nondeterministically because `t.server.latest_timestamp().await?` is the timestamp of the latest mutation, and there was a chance for the mutation to propagate to the client before the `.add_sync_query("getConversations", assert_obj!())` fully executes. So there's not always a result.

The fix is to do the second mutation after the query is registered, so waiting for the client to be aware of the mutation also means the query must be ready.

GitOrigin-RevId: 9406d69ea542af5c27ac5ebf5846789b3489978e
  • Loading branch information
ldanilek authored and Convex, Inc. committed Jan 14, 2025
1 parent 9e882ac commit b5b260f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/simulation/src/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ async fn test_sync(rt: TestRuntime) -> anyhow::Result<()> {
.await
}

#[ignore] // Test disabled due to ENG-8227
#[convex_macro::test_runtime]
async fn test_new_sync_query_after_disconnect(rt: TestRuntime) -> anyhow::Result<()> {
SimulationTest::run(
Expand All @@ -153,14 +152,14 @@ async fn test_new_sync_query_after_disconnect(rt: TestRuntime) -> anyhow::Result
t.server
.mutation("misc:init".parse()?, assert_obj!())
.await??;
t.server
.mutation("conversations:create".parse()?, assert_obj!("emoji" => "a"))
.await??;

let client = &t.js_clients[0];
let subscription_id = client
.add_sync_query("getConversations", assert_obj!())
.await?;
t.server
.mutation("conversations:create".parse()?, assert_obj!("emoji" => "a"))
.await??;
let ts = t.server.latest_timestamp().await?;
client.wait_for_server_ts(ts).await?;

Expand Down

0 comments on commit b5b260f

Please sign in to comment.