rocicorp / repc

The canonical Replicache client, implemented in Rust.
Other
30 stars 7 forks source link

structure the errors returned from repc to bindings #171

Open phritz opened 4 years ago

phritz commented 4 years ago

we are suffering from lack of structured errors returned by repc:

Note this could be solved by bringing more regularity to our rpcs a la https://github.com/rocicorp/repc/issues/119#issuecomment-691306940

phritz commented 4 years ago
   // The error paths of beginSync and maybeEndSync need to be reworked.
      //
      // We want to distinguish between:
      // a) network requests failed -- we're offline basically
      // b) sync was aborted because one's already in progress
      // c) oh noes - something unexpected happened
      //
      // Right now, all of these come out as errors. We distinguish (b) with a
      // hacky string search. (a) and (c) are not distinguishable currently
      // because repc doesn't provide sufficient information, so we treat all
      // errors that aren't (b) as (a).

-- https://github.com/rocicorp/replicache-sdk-js/blob/6a056d87b724507acb466b3aa1b921e213dac657/src/replicache.ts#L248

phritz commented 4 years ago

Another signal we want in bindings is if the diffserver got a 401 from the data layer (so bindings can trigger app-level data layer re-auth).

phritz commented 4 years ago

Ick. A failed push is not fatal for beginsync and so the push status code is correctly returned in beginsyncresponse.syncinfo.batchpushinfo.httpstatuscode. However a failed pull is fatal for the sync and so it throws an error, eg PullFailed(FetchNotOk(400)). we also have to check for PullFailed(FetchNotOk(4\d\d)) in the js :(