tonistiigi / mega

THIS REPO IS NOT MAINTAINED. Unofficial Node.js SDK for Mega
http://tonistiigi.github.com/mega
118 stars 33 forks source link

length is undefined when request fail #8

Closed anolek closed 11 years ago

anolek commented 11 years ago

Hi,

I have this exception when a request fail.

Message: Cannot read property 'length' of undefined Stacktrace --- TypeError: Cannot read property 'length' of undefined at Request.API.request as _callback at Request.init.self.callback (~/node_modules/mega/node_modules/request/main.js:122:22) at Request.EventEmitter.emit (events.js:96:17) at ClientRequest.Request.init.self.clientErrorHandler (~/node_modules/mega/node_modules/request/main.js:225:10) at ClientRequest.EventEmitter.emit (events.js:96:17) at CleartextStream.socketCloseListener (http.js:1424:9) at CleartextStream.EventEmitter.emit (events.js:126:20) at SecurePair.destroy (tls.js:956:22) at process.startup.processNextTick.process._tickCallback (node.js:245:9) Regular Caught exception: {}

To quickly fix it, i just edited api.js.

// Some error codes are returned as num, some as array with number. if (resp.length) resp = resp[0]

into

// Some error codes are returned as num, some as array with number. if (resp != undefined && resp.length) resp = resp[0]

anolek commented 11 years ago

Sorry, i just see that it's already fixed (a month ago), but even if i have mega@0.0.11, i didn't see your last commit in it. I also try "npm update" and "npm remove mega; npm install mega". Still old api.js.

tonistiigi commented 11 years ago

I released v0.0.12 and updated the npm. Should be ok now.