sourcegraph / jsonrpc2

Package jsonrpc2 provides a client and server implementation of JSON-RPC 2.0 (http://www.jsonrpc.org/specification)
MIT License
190 stars 62 forks source link

fix no corresponding request if req.ID is modified by onSend #60

Closed Semesse closed 1 year ago

Semesse commented 1 year ago

Using PickID(id) on every call works correctly, but if I try to assign IDs on the connection level I'll get an error

connOpt := jsonrpc2.OnSend(func(req *jsonrpc2.Request, res *jsonrpc2.Response) {
    if req != nil {
        req.ID = jsonrpc2.ID{
            Str:      uuid.NewString(),
            IsString: true,
        }
    }
})
jsonrpc2: ignoring response #"93eef3d4-9350-11ed-a1eb-0242ac120002" with no corresponding request
keegancsmith commented 1 year ago

staticcheck fails but that is more to do with staticcheck not working properly on go 1.16 code it seems. Wil lland this.