AuthorizeNet / sdk-node

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'slice' of undefined [bug]

fbeaver opened this issue · comments

There is a bug in apicontrollerbase.js that can crash the node instance.

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

If the request body is undefined this will fail.
We experienced this issue which crashed a production server and caused several lost transactions.

Call stack:

at IncomingMessage.emit (events.js:185:15)
at process._tickCallback (internal/process/next_tick.js:178:19)
at endReadableNT (_stream_readable.js:1106:12)
at Object.onceWrapper (events.js:272:13)
at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:1079:12)
at Request.emit (events.js:180:13)
TypeError: Cannot read property 'slice' of undefined
at Request._callback (/usr/src/app/node_modules/authorizenet/lib/apicontrollersbase.js:105:39)
at Request.self.callback (/usr/src/app/node_modules/request/request.js:185:22)
at Request.emit (events.js:180:13)
at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1157:10)
/usr/src/app/node_modules/authorizenet/lib/apicontrollersbase.js:105
var responseObj = JSON.parse(body.slice(1));

Hi,

The fix for this has been released as part of the latest version v1.0.7. I will be closing this issue now.

Feel free to reach out to us if any further issues come up.

Hi there,

since ~ October 10 our production service is failing sporadically with the 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) 

Looks like the fix is not covering all the use cases.

@gnongsie Could you please check this? it happens on production and our clients is not able to pay. Thanks.