ryan-roemer / node-sunny

Sunny.js cloud datastore client (AWS S3, Google Storage, etc.)
http://sunnyjs.org
MIT License
79 stars 13 forks source link

google connector doesn't work in node version > 0.8.23 #13

Open mikhail-spb opened 11 years ago

mikhail-spb commented 11 years ago

Updated nodejs to version 0.10.5 and get error while trying to work with google cloud storage:

TypeError: Cannot read property 'container' of null at null. (/var/www/app/ecg_service.js:228:46) at EventEmitter.emit (events.js:97:17) at AuthenticatedRequest.processResults (/var/www/app/node_modules/sunny/lib/request.js:453:10) at ClientRequest. (/var/www/app/node_modules/sunny/lib/request.js:389:16) at ClientRequest.EventEmitter.emit (events.js:116:20) at HTTPParser.parserOnIncomingClient as onIncoming at HTTPParser.parserOnHeadersComplete as onHeadersComplete at CleartextStream.socketOnData as ondata at CleartextStream.read as _read at CleartextStream.Readable.read (_stream_readable.js:283:10)

But the same script works fine in node v.0.8.23 and less

ryan-roemer commented 11 years ago

Probably hitting some snags with streams2 in v0.10.x. I'm slammed right now, but I'll see what I can do when I get some free time. My guess is that https://github.com/ryan-roemer/node-sunny/blob/master/lib/stream.js is going to need some rewriting / modifications.

In the meantime, if you or anyone you know is up on new streams and would like to tackle this, I would absolutely love a pull request!

truthspirit commented 11 years ago

I am also encountering this with aws storage. I can reproduce it just by trying to run the asyc wrapped code example from the guide page.

      containerObj = results.container;
                            ^
TypeError: Cannot read property 'container' of null
    at null.<anonymous> (/svnwork/openmx/sunnytest.js:29:29)
    at EventEmitter.emit (events.js:117:20)
    at AuthenticatedRequest.processResults (/svnwork/openmx/node_modules/sunny/lib/request.js:453:10)
    at ClientRequest.<anonymous> (/svnwork/openmx/node_modules/sunny/lib/request.js:389:16)
    at ClientRequest.EventEmitter.emit (events.js:117:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1689:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:120:23)
    at Socket.socketOnData [as ondata] (http.js:1584:20)
    at TCP.onread (net.js:525:27)

If I add the following pieces to the example code it works:

request.on('end', function (results, meta) {
      if(!results || !results.container) {
        return;
      }
      // Set container object, signal async done.

and

    request.on('end', function (results, meta) {
      if(!results || !results.blob) {
        return;
      }
      blobObj = results.blob;