Skip to content

Keyper crashes on transient RPC gateway error during subscription setup with an unwrapped error #716

Description

@ylembachar

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions