Summary
When the gateway's backend is unavailable, the Keyper exits at startup with an unwrapped error and crash-loops.
Error: json: cannot unmarshal object into Go value of type string
Root cause
The RPC gateway (gateway.fm) returns a 503 inside the result field on eth_subscribe instead of using the
JSON-RPC error field (violates JSON-RPC 2.0 §5.1):
{"jsonrpc":"2.0","result":{"code":503,"message":"server unavailable"},"id":1}
go-ethereum (rpc/handler.go:409-419) sees no top-level error, so it decodes result into the subscription-id string and fails. The error returns unwrapped from SubscribeNewHead through unsafehead.go:30-33 to the service runner to Cobra, killing the process. The same applies to WatchKeyperSetAdded (keyperset.go:69-71).
Fix
We already resubscribe on restart, so the issue is only that the subscription-setup error is returned bare and unloggable. Wrap it at the setup path in the syncers:
- unsafehead.go (~line 30): wrap the SubscribeNewHead error
- keyperset.go (~line 69): wrap the WatchKeyperSetAdded error
return errors.Wrap(err, "failed to subscribe to new heads")
Apply the same to the other syncers' Start methods (ShutterStateSyncer, EonPubKeySyncer).
Summary
When the gateway's backend is unavailable, the Keyper exits at startup with an unwrapped error and crash-loops.
Root cause
The RPC gateway (gateway.fm) returns a 503 inside the
resultfield oneth_subscribeinstead of using theJSON-RPC
errorfield (violates JSON-RPC 2.0 §5.1):go-ethereum (rpc/handler.go:409-419) sees no top-level error, so it decodes result into the subscription-id string and fails. The error returns unwrapped from SubscribeNewHead through unsafehead.go:30-33 to the service runner to Cobra, killing the process. The same applies to WatchKeyperSetAdded (keyperset.go:69-71).
Fix
We already resubscribe on restart, so the issue is only that the subscription-setup error is returned bare and unloggable. Wrap it at the setup path in the syncers:
Apply the same to the other syncers' Start methods (ShutterStateSyncer, EonPubKeySyncer).