@@ -171,7 +171,7 @@ func httpClient(ctx context.Context, addr string, namespace string, outs []inter
171171 return clientResponse {}, xerrors .Errorf ("http status %s unmarshaling response: %w" , httpResp .Status , err )
172172 }
173173
174- if resp .ID , err = translateID (resp .ID ); err != nil {
174+ if resp .ID , err = normalizeID (resp .ID ); err != nil {
175175 return clientResponse {}, xerrors .Errorf ("failed to response ID: %w" , err )
176176 }
177177
@@ -471,7 +471,7 @@ func (fn *rpcFunc) processError(err error) []reflect.Value {
471471}
472472
473473func (fn * rpcFunc ) handleRpcCall (args []reflect.Value ) (results []reflect.Value ) {
474- id : = atomic .AddInt64 (& fn .client .idCtr , 1 )
474+ var id interface {} = atomic .AddInt64 (& fn .client .idCtr , 1 )
475475 params := make ([]param , len (args )- fn .hasCtx )
476476 for i , arg := range args [fn .hasCtx :] {
477477 enc , found := fn .client .paramEncoders [arg .Type ()]
@@ -506,6 +506,16 @@ func (fn *rpcFunc) handleRpcCall(args []reflect.Value) (results []reflect.Value)
506506 retVal , chCtor = fn .client .makeOutChan (ctx , fn .ftyp , fn .valOut )
507507 }
508508
509+ // Prepare the ID to send on the wire.
510+ // We track int64 ids as float64 in the inflight map (because that's what
511+ // they'll be decoded to). encoding/json outputs numbers with their minimal
512+ // encoding, avoding the decimal point when possible, i.e. 3 will never get
513+ // converted to 3.0.
514+ id , err := normalizeID (id )
515+ if err != nil {
516+ return fn .processError (fmt .Errorf ("failed to normalize id" )) // should probably panic
517+ }
518+
509519 req := request {
510520 Jsonrpc : "2.0" ,
511521 ID : id ,
@@ -529,7 +539,6 @@ func (fn *rpcFunc) handleRpcCall(args []reflect.Value) (results []reflect.Value)
529539 }
530540
531541 var resp clientResponse
532- var err error
533542 // keep retrying if got a forced closed websocket conn and calling method
534543 // has retry annotation
535544 for attempt := 0 ; true ; attempt ++ {
0 commit comments