You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to load test gRPC service where some inputs are arrays of floats and the arrays may contain NaNvalues.
The gRPC.Client().invoke serialization fails due toNaN value being incorrectly treated as null. Same applies to Infinity values.
Error message from the gRPC invoke:
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
Similar (possibly related) behavior is visible also with console.log when logging objects/arrays where NaN values get logged as null. Logging individual NaN values works fine.
k6 version
k6 v0.54.0 (go1.23.1, darwin/amd64)
OS
MacOS 14.7
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Below is a simplified test demonstrating the behavior for both gRPC.Client().invoke and console.log:
test.js:
import{check}from'k6';importgrpcfrom'k6/net/grpc';constclient=newgrpc.Client();client.load(['.'],'dummy.proto');exportdefault()=>{client.connect('localhost:8081',{plaintext: true,});constpayload={single_float: NaN,array_float: [1.0,NaN,Infinity,-Infinity,5.0]};// Will be logged incorrectly: {"single_float":null,"array_float":[1,null,null,null,3]}console.log(payload)// Will be logged correctly: NaNconsole.log("single float",payload.single_float)// Will be logged correctlyfor(leti=0;i<payload.array_float.length;i++){console.log("array",i,payload.array_float[i])}// Will fail: GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: nullconstresponse=client.invoke('dummy.DummyService/Do',payload);console.log(response)check(response,{'status is OK': (r)=>r&&r.status===grpc.StatusOK,});client.close();};
INFO[0000] {"single_float":null,"array_float":[1,null,null,null,5]} source=console
INFO[0000] single float NaN source=console
INFO[0000] array 0 1 source=console
INFO[0000] array 1 NaN source=console
INFO[0000] array 2 Infinity source=console
INFO[0000] array 3 -Infinity source=console
INFO[0000] array 4 5 source=console
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
Expected behaviour
NaN value in the payload should be properly encoded as NaN float in the gRPC call and should not cause error.
Actual behaviour
NaN value in the payload causes error: ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
The text was updated successfully, but these errors were encountered:
I just looked into it a little bit and it would appear indeed that we apply some JSON serialization over the second argument of the invoke call under the hood:
I assume the JSON marshalling treats Nan, Infinity, and -Infinity as null (which I imagine is what JSON is supposed to do), instead of maintaining the expected representation.
Brief summary
I am trying to load test gRPC service where some inputs are arrays of floats and the arrays may contain
NaN
values.The
gRPC.Client().invoke
serialization fails due toNaN
value being incorrectly treated asnull
. Same applies to Infinity values.Error message from the gRPC invoke:
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
Similar (possibly related) behavior is visible also with
console.log
when logging objects/arrays where NaN values get logged as null. Logging individual NaN values works fine.k6 version
k6 v0.54.0 (go1.23.1, darwin/amd64)
OS
MacOS 14.7
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Below is a simplified test demonstrating the behavior for both
gRPC.Client().invoke
andconsole.log
:test.js:
dummy.proto:
resulting log messages when executing test
Expected behaviour
NaN value in the payload should be properly encoded as NaN float in the gRPC call and should not cause error.
Actual behaviour
NaN value in the payload causes error:
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
The text was updated successfully, but these errors were encountered: