Confirmed reads default only for v2 connections (#4419)

# Description of Changes

Reducing scope of https://github.com/clockworklabs/SpacetimeDB/pull/4390
to only apply to V2 clients.

# API and ABI breaking changes

I think this is an API change?

# Expected complexity level and risk

1

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
This commit is contained in:
Zeke Foppa
2026-02-23 23:27:12 -08:00
committed by GitHub
parent c37b7912b3
commit 2b85157d18
+19 -1
View File
@@ -95,6 +95,16 @@ pub struct SubscribeQueryParams {
pub confirmed: Option<bool>,
}
fn resolve_confirmed_reads_default(version: WsVersion, confirmed: Option<bool>) -> bool {
if let Some(confirmed) = confirmed {
return confirmed;
}
match version {
WsVersion::V1 => false,
WsVersion::V2 => crate::DEFAULT_CONFIRMED_READS,
}
}
pub fn generate_random_connection_id() -> ConnectionId {
ConnectionId::from_le_byte_array(rand::random())
}
@@ -170,7 +180,7 @@ where
version: negotiated.version,
compression,
tx_update_full: !light,
confirmed_reads: confirmed.unwrap_or(crate::DEFAULT_CONFIRMED_READS),
confirmed_reads: resolve_confirmed_reads_default(negotiated.version, confirmed),
};
// TODO: Should also maybe refactor the code and the protocol to allow a single websocket
@@ -2288,6 +2298,14 @@ mod tests {
assert_eq!(options, toml::from_str::<WebSocketOptions>(&toml).unwrap());
}
#[test]
fn confirmed_reads_default_depends_on_ws_version() {
assert!(resolve_confirmed_reads_default(WsVersion::V2, None));
assert!(!resolve_confirmed_reads_default(WsVersion::V1, None));
assert!(resolve_confirmed_reads_default(WsVersion::V1, Some(true)));
assert!(!resolve_confirmed_reads_default(WsVersion::V2, Some(false)));
}
#[test]
fn options_from_partial_toml() {
let toml = r#"