Make gRPC code-mode yield tests deterministic (#38321)

## What changed

- Use a never-resolving promise when verifying that a session continues to
  enforce its yield limit after terminating a cell.
- Use `yield_control()` to create the yielded cell in the notification-draining
  test instead of relying on timer scheduling.

GitOrigin-RevId: 01cdaa94e5b8b5c89c6fa98c4bbdb28a690678e0
This commit is contained in:
Channing Conger
2026-08-13 07:26:27 +00:00
committed by copyberry
parent 902bd9e06b
commit e0de12a126
2 changed files with 6 additions and 6 deletions
+5 -2
View File
@@ -877,8 +877,11 @@ async fn sessions_enforce_independent_yield_limits() -> Result<()> {
})
);
assert_eq!(
execute(&limited, request(r#"text("recovered");"#)).await?,
text_response("2", "recovered")
execute(&limited, request("await new Promise(() => {});")).await?,
RuntimeResponse::Yielded {
cell_id: cell_id("2"),
content_items: Vec::new(),
}
);
limited.shutdown().await.map_err(anyhow::Error::msg)?;
other.shutdown().await.map_err(anyhow::Error::msg)?;
@@ -183,10 +183,7 @@ async fn completed_waits_drain_pending_notifications_before_returning() -> Resul
.create_session(delegate.clone())
.await
.map_err(anyhow::Error::msg)?;
let mut pending = request(
r#"await new Promise(resolve => setTimeout(resolve, 25)); notify("notice"); text("done");"#,
);
pending.yield_time_ms = Some(/*value*/ 1);
let pending = request(r#"yield_control(); notify("notice"); text("done");"#);
let cell = session.execute(pending).await.map_err(anyhow::Error::msg)?;
assert_eq!(
cell.initial_response().await.map_err(anyhow::Error::msg)?,