roslibjs icon indicating copy to clipboard operation
roslibjs copied to clipboard

Crashing on bad JSON data

Open chrisl8 opened this issue 9 years ago • 0 comments

I am getting periodic crashes at line 104 of SocketAdapter.js when data.data is missing the closing }.

Putting the JSON.parse line into a try block prevents the crash.

Here is what data.data looks like normally: {"id": "call_service:/rosapi/get_param:25", "values": {"value": "null"}, "result": true, "service": "/rosapi/get_param", "op": "service_response"} and here is what it looks like when causing the crash: {"id": "call_service:/rosapi/get_param:575", "values": {"value": "true"}, "result": true, "service": "/rosapi/get_param", "op": "service_response" Again, just the missing final }

I can reproduce the crash by requesting parameters at a high rate. I am not sure what the cause of the bad data is though. If you have some suggestions on how to track it down I am happy to do some debugging. Otherwise I suggest just putting the JSON.parse line in a try block and ignoring bad data to prevent crashing.

chrisl8 avatar Sep 19 '16 14:09 chrisl8