diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c46f29232578..cffe0b8056b29f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ Release channels have their own copy of this changelog: ## 3.0.0 - Unreleased +### RPC + +#### Changes +* The subscription server now prioritizes processing received messages before sending out responses. This ensures that new subscription requests and time-sensitive messages like `PING` opcodes take priority over notifications. + ### Validator #### Breaking diff --git a/rpc/src/rpc_pubsub_service.rs b/rpc/src/rpc_pubsub_service.rs index 0cb602982e707c..8187741f442ebc 100644 --- a/rpc/src/rpc_pubsub_service.rs +++ b/rpc/src/rpc_pubsub_service.rs @@ -401,6 +401,12 @@ async fn handle_connection( pin!(receive_future); loop { select! { + biased; // See [prioritization] note below. + + // [prioritization] + // This block must come FIRST in the `select!` macro. This prioritizes + // processing received messages over sending messages. This ensures the timely + // processing of new subscriptions and time-sensitive opcodes like `PING`. result = &mut receive_future => match result { Ok(_) => break, Err(soketto::connection::Error::Closed) => return Ok(()),