actions-on-google / actions-on-google-nodejs

Node.js client library for Actions on Google
https://actions-on-google.github.io/actions-on-google-nodejs
Apache License 2.0
900 stars 197 forks source link

SyntaxError excpetion thrown in response of requestSync method is not rejected properly and crashes #363

Open aidinrs opened 4 years ago

aidinrs commented 4 years ago

If response of the call to requestSync method is not in proper JSON then the response handler throws SyntaxError exception at JSON.parse, without rejecting the promise causing the whole node application to crash. it should be wrapped around a try-catch block and rejected properly.

Fleker commented 4 years ago

So you're calling requestSync with some data, but for some reason it fails and it sends you a non-JSON body?

aidinrs commented 4 years ago

@Fleker yes, I saw it in the logs a few times. I saw 403 unauthorized errors. Anyway, there certainly is a chance of it failling thus it should be wrapped around try-catch. for example google service not responding properly, being down or if you proxied the request and the proxy being down, .... this should not take my whole application down.