pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
552 stars 403 forks source link

Strange error events with node.js #19

Closed herzi closed 10 years ago

herzi commented 10 years ago

I wrote a node.js script which essentially does this:

// some code here

pubnub.subscribe({
    channel: 'some channel id',
    callback: function () {/* … */},
    connect: function () {/* … */},
    disconnect: function () {/* … */},
    reconnect: function () {/* … */},
    error: function (error) {
        if (error === undefined) {
            throw new Error('unexpected error: ' +
                            util.inspect(error));
        }
        /* … */
    }
});

// some code here

Here is what I caught:

Error: unexpected error: undefined
    at <anonymous> (<the line of my throw statement above>)
    at SELF.subscribe.xdr.fail (~/node_modules/pubnub/pubnub.js:637:25)
    at done (~/node_modules/pubnub/pubnub.js:1084:23)
    at finished (~/node_modules/pubnub/pubnub.js:1068:32)
    at IncomingMessage.<anonymous> (~/node_modules/pubnub/pubnub.js:1124:17)
    at IncomingMessage.EventEmitter.emit (events.js:126:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
    at Socket.socketOnData [as ondata] (http.js:1367:20)
    at TCP.onread (net.js:404:27)

This is node.js v0.8.16 with pubnub@3.5.48.

stephenlb commented 10 years ago

I believe that "error" callback does not provide an error parameter.

stephenlb commented 10 years ago

Oh wait! Also, the "error" callback is used with PubNub Access Manager: http://www.pubnub.com/docs/javascript/overview/security.html#_access_manager_api_functions

geremyCohen commented 10 years ago

escalating to @devendram

herzi commented 10 years ago

@stephenlb It does. I'm actually checking arguments.length in the beginning of my callback :-) It is one.

stephenlb commented 10 years ago

@herzi ah.. good! Do you have PAM enabled?

herzi commented 10 years ago

How do I enable PAM and what do I used it for? (I'm running a client for Mt.Gox's API, do I actually need to care about PAM?)

geremyCohen commented 10 years ago

@herzi http://www.pubnub.com/docs/javascript/tutorial/access-manager.html - let us know if that works for you.

geremyCohen commented 10 years ago

@herzi for the Public feeds, you do not need PAM: https://en.bitcoin.it/wiki/MtGox/API/Pubnub

geremyCohen commented 10 years ago

@herzi for now, some errors may be undefined -- we are addressing this for the next release.