Skip to content

Commit

Permalink
Hotfix srv middleware panic on missing jsonrpc id (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanliqun committed Mar 28, 2024
1 parent a3b542a commit 45ef42c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rpc/server_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ func MustInit() {
// cfx/eth client
rpc.HookHandleCallMsg(clientMiddleware)

// invalid json rpc request without `ID`
rpc.HookHandleCallMsg(rpc.PreventMessagesWithouID)

// uniform human-readable error message
rpc.HookHandleCallMsg(middlewares.UniformError)

// invalid json rpc request without `ID`
// !!! This should always be checked at first as we might suffer nil pointer panic due to
// missing jsonrpc `ID` for following middleware executions.
rpc.HookHandleCallMsg(rpc.PreventMessagesWithouID)
}

// Inject values into context for static RPC call middlewares, e.g. rate limit
Expand Down

0 comments on commit 45ef42c

Please sign in to comment.