sdk-node icon indicating copy to clipboard operation
sdk-node copied to clipboard

Uncaught SyntaxError

Open ForestBeaver opened this issue 5 years ago • 5 comments

Had a server crash with the trace: SyntaxError: Unexpected token H in JSON at position 0

https://github.com/AuthorizeNet/sdk-node/blob/aab2dac8bb057e5f245a8a52dea017f71e1a36e2/lib/apicontrollersbase.js#L102

ForestBeaver avatar Apr 30 '19 18:04 ForestBeaver

Looks like the server was returning

HTML><HEAD>

ForestBeaver avatar Apr 30 '19 18:04 ForestBeaver

Hi,

Can you please provide information about the request you are sending and the full response you get from the servers?

gnongsie avatar May 02 '19 06:05 gnongsie

the same issue

[email protected]

2019-11-15T16:25:01.121Z error: uncaughtException: Unexpected token H in JSON at position 0 
SyntaxError: Unexpected token H in JSON at position 0 
    at JSON.parse (<anonymous>) 
    at Request._callback (/app/node_modules/authorizenet/lib/apicontrollersbase.js:102:29) 
    at Request.self.callback (/app/node_modules/request/request.js:185:22) 
    at Request.emit (events.js:210:5) 
    at Request.EventEmitter.emit (domain.js:476:20) 
    at Request.<anonymous> (/app/node_modules/request/request.js:1161:10) 
    at Request.emit (events.js:210:5) 
    at Request.EventEmitter.emit (domain.js:476:20) 
    at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1083:12) 
    at Object.onceWrapper (events.js:299:28) 
    at IncomingMessage.emit (events.js:215:7) 
    at IncomingMessage.EventEmitter.emit (domain.js:476:20) 
    at endReadableNT (_stream_readable.js:1183:12) 
    at processTicksAndRejections (internal/process/task_queues.js:80:21) SyntaxError: Unexpected token H in JSON at position 0 
    at JSON.parse (<anonymous>) 
    at Request._callback (/app/node_modules/authorizenet/lib/apicontrollersbase.js:102:29) 
    at Request.self.callback (/app/node_modules/request/request.js:185:22) 
    at Request.emit (events.js:210:5) 
    at Request.EventEmitter.emit (domain.js:476:20) 
    at Request.<anonymous> (/app/node_modules/request/request.js:1161:10) 
    at Request.emit (events.js:210:5) 
    at Request.EventEmitter.emit (domain.js:476:20) 
    at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1083:12) 
    at Object.onceWrapper (events.js:299:28) 
    at IncomingMessage.emit (events.js:215:7) 
    at IncomingMessage.EventEmitter.emit (domain.js:476:20) 
    at endReadableNT (_stream_readable.js:1183:12) 

This happens when your server gives a 500 error. By the way, today your system has been buggy for about 15 minutes, while nothing is said about this in your monitoring system!

https://status.authorize.net/ Authorize Net+Status+2019-11-15+21-37-30

ruscon avatar Nov 15 '19 16:11 ruscon

I can confirm this issue again.

The block is not in try catch and causes a server crash. Happening a lot of times now and sometimes the payment also goes through but it returns the above response which is very strange.

Is there anyone looking into it? I can submit a pull request to at least add better error handling to avoid crashes.

suroorwijdan avatar Feb 14 '20 06:02 suroorwijdan

Is this issue being looked at? I have just gotten the same issue and it seems to be still existing in latest version of the SDK.

amr-labib avatar Jun 28 '21 03:06 amr-labib

TCS-Dev saikumarkale- issue is fixed in the latest patch, September 2024 Release - v1.0.9

saikumarkale avatar Sep 30 '24 13:09 saikumarkale