Wednesday 14 June 2017

New to Node: How to best troubleshoot error?

Hey Guys,I have a project I'm working on where I'm running into an error in one of my API endpoints. The API accepts and parses a JSON (Watson speech to text transcription).The error only occurs when the JSON sent to it is large. (6min video no issues, 1 hour video causes 500 error).The error does not crash the app but causes a 500 error and the route exits prematurely. I've identified the code that causes the error:let confidenceSum = wordConfidenceArr.reduce((total, num) => { return total + num[1]; }, 0); My question is more general than just what's wrong with my code. My question is how do I go about troubleshooting the error? All I see is the console error:Write JSON Write TEXT get wordConfidenceArr add wordConfidencetotal POST /api/watson/results 500 451.141 ms - 3346 edit: What I've done so far to troubleshoot is add a whole bunch of console logs to see where the error occurs. I've also commented out that specific peace of code and that gets rid of the error. As far as I can tell the reduce method is correct, and seems to work on smaller JSON samples. I will try to rewrite the .reduce with a plain for loop but don't know why it would fail in the first place.Thanks for your help in advance!

Submitted June 14, 2017 at 04:52PM by b0z33

No comments:

Post a Comment