AuthorizeNet / sdk-node

Node.js SDK for the Authorize.Net payments platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught SyntaxError

ForestBeaver opened this issue · comments

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

var responseObj = JSON.parse(body.slice(1));

Looks like the server was returning

HTML><HEAD>

Hi,

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

the same issue

authorizenet@1.0.7

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

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.

commented

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.