Skip to content

Commit 111c277

Browse files
committed
fix: prevent reporting http errors in sync_offline
resolves #1919
1 parent 573ba92 commit 111c277

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

libsql/src/local/database.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,7 @@ impl Database {
478478
Err(Error::Sync(err)) => {
479479
// Retry the sync because we are ahead of the server and we need to push some older
480480
// frames.
481-
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) =
482-
err.downcast_ref::<SyncError>()
483-
{
481+
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) = err.downcast_ref() {
484482
tracing::debug!("got InvalidPushFrameNo, retrying push");
485483
self.try_push(&mut sync_ctx, &conn).await
486484
} else {
@@ -492,6 +490,22 @@ impl Database {
492490
} else {
493491
self.try_pull(&mut sync_ctx, &conn).await
494492
}
493+
.or_else(|err| {
494+
let Error::Sync(err) = err else {
495+
return Err(err);
496+
};
497+
498+
// TODO(levy): upcasting should be done *only* at the API boundary, doing this in
499+
// internal code just sucks.
500+
let Some(SyncError::HttpDispatch(_)) = err.downcast_ref() else {
501+
return Err(Error::Sync(err));
502+
};
503+
504+
Ok(crate::database::Replicated {
505+
frame_no: None,
506+
frames_synced: 0,
507+
})
508+
})
495509
}
496510

497511
#[cfg(feature = "sync")]

0 commit comments

Comments
 (0)