Skip to content

Commit

Permalink
fix: prevent reporting http errors in sync_offline
Browse files Browse the repository at this point in the history
resolves #1919
  • Loading branch information
levydsa committed Jan 17, 2025
1 parent 573ba92 commit 111c277
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions libsql/src/local/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,7 @@ impl Database {
Err(Error::Sync(err)) => {
// Retry the sync because we are ahead of the server and we need to push some older
// frames.
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) =
err.downcast_ref::<SyncError>()
{
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) = err.downcast_ref() {
tracing::debug!("got InvalidPushFrameNo, retrying push");
self.try_push(&mut sync_ctx, &conn).await
} else {
Expand All @@ -492,6 +490,22 @@ impl Database {
} else {
self.try_pull(&mut sync_ctx, &conn).await
}
.or_else(|err| {
let Error::Sync(err) = err else {
return Err(err);
};

// TODO(levy): upcasting should be done *only* at the API boundary, doing this in
// internal code just sucks.
let Some(SyncError::HttpDispatch(_)) = err.downcast_ref() else {
return Err(Error::Sync(err));
};

Ok(crate::database::Replicated {
frame_no: None,
frames_synced: 0,
})
})
}

#[cfg(feature = "sync")]
Expand Down

0 comments on commit 111c277

Please sign in to comment.