tonistiigi / mega

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

Cannot read property 'length' of undefined (storage.js) #9

Closed anolek closed 11 years ago

anolek commented 11 years ago

Hi,

I have an exception when sometimes, a request fail in storage.js

Message: Cannot read property 'length' of undefined

TypeError: Cannot read property 'length' of undefined at Object.exports.d64 (~/node_modules/mega/lib/crypto/index.js:17:24) at Storage._createUser (~/node_modules/mega/lib/storage.js:151:22) at Request.API.request as _callback

I think that we need to throw an error or check if "response.tsid" exists in storage.js at line 151 :

(storage.js near line 151) self.api.request({a: 'us', user: user}, function(err, response) { // maybe add "if(err) cb(err)" here var t = crypto.d64(response.tsid) // here, response.tsid is undefined

Thanks !

tonistiigi commented 11 years ago

Fixed. Thanks for reporting.