Skip to content

Callback never called #84

@oreynaldocl

Description

@oreynaldocl

Hello.
I found an interesting problem. It only happened when I debugged my code.
If for some reason I lose the connection of DDP(not closed or error) if I call .subscribe or .call the callback is never called.
Debugging I lost the connection because the socket can't resolve ping-pong process and it set its readyState to 2
I debugged really deep and I found this code

// .../node_modules/ddp/lib/ddp-client.js
DDPClient.prototype.subscribe = function(name, params, callback) {
  ...
  self._callbacks[id] = callback;
  ...
  self._send({
    msg    : "sub",
    ...
  });
};
DDPClient.prototype._send = function(data) {
  this.socket.send(
    EJSON.stringify(data)
  );
};

// .../node_modules/ddp/node_modules/faye-websocket/lib/faye/websocket/api.js
  send: function(data) {
    if (this.readyState > API.OPEN) return false;
    if (!(data instanceof Buffer)) data = String(data);
    return this._driver.messages.write(data);
  },

This condition if (this.readyState > API.OPEN) is true and the socket never sends the message but the DDP added the callback but it never has an answer message for this callback and it will been waiting forever for this callback.

Without debugging this error never happens, but I think is really dangerous that the DDP don't manage this problem, it can happen and the DDP will wait forever.

Anybody had this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions