Skip to content

Commit

Permalink
Backend/Ether: catch/retry new -32002 err code
Browse files Browse the repository at this point in the history
Fix cherry-picked from stable branch:

CI on master branch caught this[1]:

```
Unhandled Exception:
System.AggregateException: One or more errors occurred. (Some problem when connecting to 'api.mycryptoapi.com/eth') ---> System.Exception: Some problem when connecting to 'api.mycryptoapi.com/eth' ---> System.Exception: RpcResponseException with RpcError Code <-32002> and Message 'rejected due to project ID settings' (rejected due to project ID settings) ---> JsonRpcSharp.Client.RpcResponseException: rejected due to project ID settings
  at JsonRpcSharp.Client.ClientBase.HandleRpcError (JsonRpcSharp.Client.RpcMessages.RpcResponseMessage response) [0x00033] in <4c31088b87e449d8935ce2e038670d08>:0
  at JsonRpcSharp.Client.ClientBase.SendInnerRequestAsync[T] (JsonRpcSharp.Client.RpcMessages.RpcRequestMessage reqMsg, System.String route, System.Threading.CancellationToken cancellationToken) [0x00089] in <4c31088b87e449d8935ce2e038670d08>:0
  at JsonRpcSharp.Client.ClientBase.SendInnerRequestAsync[T] (JsonRpcSharp.Client.RpcRequest request, System.String route, System.Threading.CancellationToken cancellationToken) [0x000a3] in <4c31088b87e449d8935ce2e038670d08>:0
  at JsonRpcSharp.Client.ClientBase.SendRequestAsync[T] (JsonRpcSharp.Client.RpcRequest request, System.String route, System.Threading.CancellationToken cancellationToken) [0x00127] in <4c31088b87e449d8935ce2e038670d08>:0
   --- End of inner exception stack trace ---
  at GWallet.Backend.Ether.Server.MaybeRethrowRpcResponseException (System.Exception ex) [0x001a9] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:224
  at GWallet.Backend.Ether.Server.ReworkException (System.Exception ex) [0x0000e] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:299
  at GWallet.Backend.Ether.Server+HandlePossibleEtherFailures@387-6[R].Invoke (System.Exception _arg2) [0x00002] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:392
  at GWallet.Backend.Ether.Server+HandlePossibleEtherFailures@387-8[R].Invoke (System.Exception exn) [0x00000] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:387
  at GWallet.Backend.Ether.Server+HandlePossibleEtherFailures@387-10[R].Invoke (System.Exception edi) [0x00000] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:387
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x00005] in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:435
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:109
   --- End of inner exception stack trace ---
  at GWallet.Backend.Ether.Server+Web3ServerToRetrievalFunc@406-2[R].Invoke (System.Exception _arg3) [0x00060] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:415
  at GWallet.Backend.Ether.Server+Web3ServerToRetrievalFunc@406-5[R].Invoke (System.Exception exn) [0x00000] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:406
  at GWallet.Backend.Ether.Server+Web3ServerToRetrievalFunc@406-7[R].Invoke (System.Exception edi) [0x00000] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/Ether/EtherServer.fs:406
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x00005] in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:435
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:109
--- End of stack trace from previous location where exception was thrown ---

  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in /Users/runner/work/geewallet/geewallet/src/GWallet.Backend/FSharpUtil.fs:206
...
```

[1] https://github.com/nblockchain/geewallet/actions/runs/3507005645/jobs/5874411684
  • Loading branch information
knocte committed Dec 26, 2022
1 parent 6b72502 commit 712b6b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/GWallet.Backend/Ether/EtherExceptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type RpcErrorCode =
// so many different errors use this shitty error code... don't ask me why
| JackOfAllTradesErrorCode = -32000

// message was "rejected due to project ID settings" (don't ask me wtf this means)
| ProjectIdSettingsRejection = -32002

// ambiguous or generic because I've seen same code applied to two different error messages already:
// "Transaction with the same hash was already imported. (Transaction with the same hash was already imported.)"
// AND
Expand Down
4 changes: 3 additions & 1 deletion src/GWallet.Backend/Ether/EtherServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ module Server =
raise <| ServerMisconfiguredException(exMsg, rpcResponseEx)
| d when d = int RpcErrorCode.EmptyResponse ->
raise <| ServerMisconfiguredException(exMsg, rpcResponseEx)
| e when e = int RpcErrorCode.DailyRequestCountExceededSoRequestRateLimited ->
| e when e = int RpcErrorCode.ProjectIdSettingsRejection ->
raise <| ServerRefusedException(exMsg, rpcResponseEx)
| f when f = int RpcErrorCode.DailyRequestCountExceededSoRequestRateLimited ->
raise <| ServerRefusedException(exMsg, rpcResponseEx)
| _ ->
raise
Expand Down

0 comments on commit 712b6b2

Please sign in to comment.