node-red-web-nodes icon indicating copy to clipboard operation
node-red-web-nodes copied to clipboard

Google Place: Unexpected token < in JSON at position 0

Open beneuto opened this issue 7 years ago • 1 comments

Node-red is frequently (but not always) crashing with the following error when performing a Google Places Nearby lookup. All parameters are hard coded into the node itself except for Name which is passed in via message. The name values are simple and do not contain unusual characters. I have even added preprocessing to strip out non-alphanumeric characters to be sure.

18 Apr 14:55:33 - SyntaxError: Unexpected token < in JSON at position 0 at Object.parse (native) at Request._callback (C:\Users\iccadmin.node-red\node_modules\node-red-node-google\places.js:254:33) at Request.self.callback (C:\Users\iccadmin.node-red\node_modules\node-red-node-google\node_modules\request\request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (C:\Users\iccadmin.node-red\node_modules\node-red-node-google\node_modules\request\request.js:1044:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (C:\Users\iccadmin.node-red\node_modules\node-red-node-google\node_modules\request\request.js:965:12) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

beneuto avatar Apr 18 '17 05:04 beneuto

After some further testing I suspect that the issue may be caused by the payload length exceeding some input limit. I have isolated a test message that will cause the failure, but if I delete some arbitrary properties it will work (I have done this with different sets of properties at random and it always works).

This is easily worked around by deleting the payload before the Google Place node. That is fine since the payload will be overwritten anyway. The issue appears to be specific to the payload size (rather than overall message size) as originally I had 2 copies of the payload going into the Google node (in anticipation of the payload being overwritten) and if I delete the copy instead of the payload the crash still occurs.

beneuto avatar Apr 18 '17 07:04 beneuto