chore: add more detailed logging around errors in Transaction::try_encode_state_as_update_v1 (#514)

This commit is contained in:
Bartosz Sypytkowski 2024-05-01 14:14:27 +02:00 committed by GitHub
parent 79bb510aaf
commit 29928cb4a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 12 deletions

View File

@ -52,7 +52,7 @@ impl CollabSyncProtocol for ClientSyncProtocol {
RTProtocolError::YrsTransaction(format!("sync step2 transaction acquire: {}", err)) RTProtocolError::YrsTransaction(format!("sync step2 transaction acquire: {}", err))
})?; })?;
txn.try_apply_update(update).map_err(|err| { txn.try_apply_update(update).map_err(|err| {
RTProtocolError::YrsApplyUpdate(format!("sync step2 apply update: {}", err)) RTProtocolError::YrsApplyUpdate(format!("sync step2 apply update: {} ", err))
})?; })?;
// If the client can't apply broadcast from server, which means the client is missing some // If the client can't apply broadcast from server, which means the client is missing some
@ -121,16 +121,17 @@ pub trait CollabSyncProtocol {
awareness: &Awareness, awareness: &Awareness,
sv: StateVector, sv: StateVector,
) -> Result<Option<Vec<u8>>, RTProtocolError> { ) -> Result<Option<Vec<u8>>, RTProtocolError> {
let update = awareness let txn = awareness.doc().try_transact().map_err(|err| {
.doc() RTProtocolError::YrsTransaction(format!("fail to handle sync step1. error: {}", err))
.try_transact() })?;
.map_err(|err| { let update = txn.try_encode_state_as_update_v1(&sv).map_err(|err| {
RTProtocolError::YrsTransaction(format!("fail to handle sync step1. error: {}", err)) RTProtocolError::YrsEncodeState(format!(
})? "fail to encode state as update. error: {}\ninit state vector: {:?}\ndocument state: {:#?}",
.try_encode_state_as_update_v1(&sv) err,
.map_err(|err| { sv,
RTProtocolError::YrsEncodeState(format!("fail to encode state as update. error: {}", err)) txn.store()
})?; ))
})?;
Ok(Some( Ok(Some(
Message::Sync(SyncMessage::SyncStep2(update)).encode_v1(), Message::Sync(SyncMessage::SyncStep2(update)).encode_v1(),
)) ))

View File

@ -21,7 +21,12 @@ impl CollabSyncProtocol for ServerSyncProtocol {
})?; })?;
let client_step2_update = txn.try_encode_state_as_update_v1(&sv).map_err(|err| { let client_step2_update = txn.try_encode_state_as_update_v1(&sv).map_err(|err| {
RTProtocolError::YrsEncodeState(format!("fail to encode state as update. error: {}", err)) RTProtocolError::YrsEncodeState(format!(
"fail to encode state as update. error: {}\ninit state vector: {:?}\ndocument state: {:#?}",
err,
sv,
txn.store()
))
})?; })?;
// Retrieve the latest document state from the client after they return online from offline editing. // Retrieve the latest document state from the client after they return online from offline editing.