TrojanerHD / TrojanerBot

My discord bot
MIT License
4 stars 2 forks source link

Unexpected token c in JSON at position 0 #1

Closed TrojanerHD closed 2 years ago

TrojanerHD commented 3 years ago

Randomly occurs after some time when starting the bot (in this case it took a few hours/days)

Probably some error handling is required in general

FetchError: invalid json response body at https://api.twitch.tv/helix/streams?user_login=<username>&user_login=<other username>&… reason: Unexpected token c in JSON at position 0
    at /home/trojaner/Code/Web/TrojanerBot/node_modules/node-fetch/lib/index.js:272:32
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  type: 'invalid-json'
}

/home/trojaner/Code/Web/TrojanerBot/node_modules/node-fetch/lib/index.js:272
                                return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
                                                           ^
FetchError: invalid json response body at https://api.twitch.tv/helix/games? reason: Unexpected token c in JSON at position 0
    at /home/trojaner/Code/Web/TrojanerBot/node_modules/node-fetch/lib/index.js:272:32
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  type: 'invalid-json'
}
TrojanerHD commented 3 years ago

This is difficult to fix since this error occurs rarely. I will continue to monitor the bug

TrojanerHD commented 3 years ago

Also https://github.com/TrojanerHD/TrojanerBot/commit/0f04d3ae04f0f216f3d1b2c72b9d97db3d3e4fd7 was created so the log is more verbose on branch unstable

TrojanerHD commented 2 years ago

Since now, this bug never occurred again. It is considered fixed until it should show up again