Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livequery process, keeps throwing errors when the live result is not the first in the processing queue #36

Open
imdark opened this issue Jul 7, 2015 · 11 comments
Assignees

Comments

@imdark
Copy link

imdark commented Jul 7, 2015

In cases when the processing queue contains LIVE_RESULT only on the second or third member it throws an
Unhandled rejection OrientDB.ProtocolError:
Unsupported operation status: 6
while 6 is the LIVE_RESULT operation status and should be fully supported
this mostly happens when quite a few updates are very quickly emited

Connection.prototype.process = function (buffer, offset) {
  var code, parsed, result, status, item, op, deferred, err, token, operation;
  offset = offset || 0;
  if(this.queue.length === 0){
    op = new Operation();//TODO refactor this!
    parsed = op.consume(buffer, offset);
    status = parsed[0];
    if (status === OperationStatus.PUSH_DATA) {
      offset = parsed[1];
      result = parsed[2];
      this.emit('update-config', result);
      return offset;
    }else if(status === OperationStatus.LIVE_RESULT){
      token = parsed[1];
      operation = parsed[2];
      result = parsed[3];
      offset = parsed[4];
      this.emit('live-query-result', token, operation, result);
      return offset;
    }
  }
  while ((item = this.queue.shift())) {
    op = item[0];
    deferred = item[1];
    parsed = op.consume(buffer, offset);
    status = parsed[0];
    offset = parsed[1];
    result = parsed[2];
    if (status === OperationStatus.READING) {
      // operation is incomplete, buffer does not contain enough data
      this.queue.unshift(item);
      return offset;
    }
    else if (status === OperationStatus.PUSH_DATA) {
      this.emit('update-config', result);
      this.queue.unshift(item);
      return offset;
    }
    else if (status === OperationStatus.COMPLETE) {
      deferred.resolve(result);
    }
    else if (status === OperationStatus.ERROR) {
      if (result.status.error) {
        // this is likely a recoverable error
        deferred.reject(result.status.error);
      }
      else {
        // cannot recover, reject everything and let the application decide what to do
        err = new errors.Protocol('Unknown Error on operation id ' + op.id, result);
        deferred.reject(err);
        this.cancel(err);
        this.emit('error', err);
      }
    }
    else {
      deferred.reject(new errors.Protocol('Unsupported operation status: ' + status));
    }
  }
  return offset;
};
@luigidellaquila luigidellaquila added this to the 2.2 milestone Jul 13, 2015
@joaobarcia
Copy link

Hi @lvca ,

Any progress on this issue? Is it still assigned to 2.2? It seems to be the only issue preventing OrientDB from being integrated into Meteor.

@imdark seems to be unresponsive this past few weeks.

Cheers

@kaYcee
Copy link

kaYcee commented Mar 2, 2016

Hi, We're trying to incorporate LiveQuery in our node project and always receive a particular error once multiple updates are carried out in quite a short time.

db.liveQuery("LIVE SELECT FROM FooClass").on('live-update', function(data) {
console.log("Emitting update");
});

is returning:
Emitting update
Emitting update
Unhandled rejection OrientDB.ProtocolError: Unsupported operation status: 6 at Connection.process (/.../node_modules/orientjs/lib/transport/binary/connection.js:415:23) at Connection.handleSocketData (/.../node_modules/orientjs/lib/transport/binary/connection.js:281:17) at emitOne (events.js:90:13) at Socket.emit (events.js:182:7) at readableAddChunk (_stream_readable.js:147:16) at Socket.Readable.push (_stream_readable.js:111:10) at TCP.onread (net.js:525:20)

We're using OrientDB 2.1.12 (but has been observed since 2.1.8) and OrientJS 2.1.11. Also tried with the respective 2.2 versions but in that case the callback is never called (although the very same database has cleanly been imported into both OrientDB instances), we just can't get it running in 2.2. Are any additional configuration steps necessary for 2.2 to make LiveQuery in node.js work? (btw also tried with the OrientJS 2.2.x branch - no luck).

We also tried the suggested fix (#43 transport fix for live query) - but unfortunately this lead to other errors.

Anyone experiencing similar issues? Thanks

@wolf4ood
Copy link
Member

wolf4ood commented Mar 2, 2016

hi @kaYcee

i'm looking at it now.

I will let you know

@iamlogiq
Copy link

iamlogiq commented Jun 18, 2016

I'm having the same issue with OrientDb v.2.2.2. The callback for LiveQuery is NEVER called!

@iamlogiq
Copy link

hey @kaYcee any news when this will be fixed...Live Query has been unusable for me since i'm relying the orientjs API.

@wolf4ood
Copy link
Member

hi @iamlogiq

which version of OrientDB and OrientJS?

@iamlogiq
Copy link

@maggiolo00
Im using orientdb 2.2.8
"orientjs": "^2.2.2"

The callbacks ('live-insert, live-delete, live-update) for LiveQuery are NEVER called!

@wolf4ood
Copy link
Member

@iamlogiq

can you provide a test script ?

they are running fine in tests

https://github.com/orientechnologies/orientjs/blob/master/test/db/live-query.js

@wolf4ood
Copy link
Member

@iamlogiq

can you add the config

useToken : true

in the configuration? it should resolve

@iamlogiq
Copy link

iamlogiq commented Sep 3, 2016

@maggiolo00 Which config file are you referring to?

@wolf4ood
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants