ipinfo / node

Official Node client library for IPinfo API (IP geolocation and other types of IP data)
https://ipinfo.io
Apache License 2.0
157 stars 33 forks source link

SyntaxError: Unexpected token ';', ";{ #89

Open mojidev7 opened 2 months ago

mojidev7 commented 2 months ago

Looks like something is wrong here:

SyntaxError: Unexpected token ';', ";{
  "ip":"... is not valid JSON
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (C:\Users\Administrator\Desktop\data-analysis-co\node_modules\node-ipinfo\dist\src\ipinfoWrapper.js:109:67)
    at IncomingMessage.emit (node:events:519:28)
    at emitCloseNT (node:internal/streams/destroy:147:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

this error came from this line, maybe malformed response.

mojidev7 commented 2 months ago

that's a very simple case:

Example:

function foo() {
    console.log('Hi');
    setTimeout(() => {
        console.log('lets throwing an exception.. :}}')
        throw new Error('An Amazing Error!');
    }, 2000)
}

try {
    foo()
} catch (error) {
    console.log('Error Catched!: ' + error);
}

Output:

Hi
lets throwing an exception.. :}}
/Users/mojtaba/personalp/test.js:5
        throw new Error('An Amazing Error!');
        ^

Error: An Amazing Error!
    at Timeout._onTimeout (/Users/mojtaba/personalp/test.js:5:15)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Node.js v20.15.1

We can see that Error Catched! is not here..

abdullahdevrel commented 1 month ago

Hi @mojidev7 Which version of node-ipinfo are you using?

If it's < 3.1.1 then the issue is that they don't have a fix for this issue which was added in July 2022.

Let me know if the error persists after the update.

pz129 commented 2 weeks ago

I this still happening (very rarely) in 3.5.3

abdullahdevrel commented 2 weeks ago

We will look into this as soon as possible.

CC: @max-ipinfo

abdullahdevrel commented 1 week ago

@pz129 We are investigating the issues, and are currently unsure how to replicate the scenario. Can you please reach out to us through our support desk (support@ipinfo.io)? We would appreciate more information from you. Thanks!

Best Regards, Abdullah (DevRel @ IPinfo.io)