speedcontrol / nodecg-speedcontrol

NodeCG bundle to help facilitate the running of speedrunning marathons, including overlays.
MIT License
44 stars 34 forks source link

Uncaught exception crashing NodeCG when the twitch api can't get reached #25

Closed gaeldemarseille closed 5 years ago

gaeldemarseille commented 6 years ago

I was testing speedcontrol and my internet might have gone down and it crashed

UNCAUGHT EXCEPTION! NodeCG will now exit.
TypeError: Cannot read property 'body' of undefined
    at needle.get (C:\Users\Gael\Desktop\nodecg\bundles\nodecg-speedcontrol\extension\twitchapi.js:81:13)
    at done (C:\Users\Gael\Desktop\nodecg\bundles\nodecg-speedcontrol\node_modules\needle\lib\needle.js:432:14)
    at ClientRequest.had_error (C:\Users\Gael\Desktop\nodecg\bundles\nodecg-speedcontrol\node_modules\needle\lib\needle.js:442:5)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
zoton2 commented 6 years ago

The web requests in the twitchapi.js file need some more logic for checking for errors and retrying still, which would fix this issue.

zoton2 commented 6 years ago

I am currently getting quite a few "Cannot read property 'body' of undefined" in relation to this, not on the same lines either, this should really be fixed before ESA.

zoton2 commented 6 years ago

On ESA branch, have implemented some retrying code for the 2 most important parts, checkTokenValidity and updateToken, the rest still needs some improving though. This is enough to remove the esa-summer-2018 label.

zoton2 commented 5 years ago

Going to close this for now, haven't had this actual issue happen for a while, the Twitch API implementation could do with some improvement but that needs to be a separate issue.