node
node copied to clipboard
SyntaxError: Unexpected token ; in JSON at position 0
My server just crashed after few months using this library.
I'm using try/catch, but I think the error was caused by an event listener block and my code couldn't handle it.
Log:
undefined:1
;{
^
SyntaxError: Unexpected token ; in JSON at position 0
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (/**/node_modules/node-ipinfo/dist/src/ipinfoWrapper.js:109:67)
at IncomingMessage.emit (node:events:517:28)
at emitCloseNT (node:internal/streams/destroy:132:10)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
Node.js v18.20.4
error Command failed with exit code 1.
To avoid these crashes, it would be good to have the try/catch block in JSON.parse on these lines:
113: https://github.com/ipinfo/node/blob/v3.5.1/src/ipinfoWrapper.ts#L113 210: https://github.com/ipinfo/node/blob/v3.5.1/src/ipinfoWrapper.ts#L210 293: https://github.com/ipinfo/node/blob/v3.5.1/src/ipinfoWrapper.ts#L293 451: https://github.com/ipinfo/node/blob/v3.5.1/src/ipinfoWrapper.ts#L451
Version:
node-ipinfo: "^3.5.1"