orientjs icon indicating copy to clipboard operation
orientjs copied to clipboard

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

Open imdark opened this issue 10 years ago • 11 comments

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;
};

imdark avatar Jul 07 '15 21:07 imdark

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

joaobarcia avatar Sep 06 '15 22:09 joaobarcia

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

kaYcee avatar Mar 02 '16 12:03 kaYcee

hi @kaYcee

i'm looking at it now.

I will let you know

wolf4ood avatar Mar 02 '16 13:03 wolf4ood

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

iamlogiq avatar Jun 18 '16 02:06 iamlogiq

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

iamlogiq avatar Aug 11 '16 13:08 iamlogiq

hi @iamlogiq

which version of OrientDB and OrientJS?

wolf4ood avatar Aug 11 '16 14:08 wolf4ood

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

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

iamlogiq avatar Aug 30 '16 23:08 iamlogiq

@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 avatar Aug 31 '16 09:08 wolf4ood

@iamlogiq

can you add the config

useToken : true

in the configuration? it should resolve

wolf4ood avatar Aug 31 '16 10:08 wolf4ood

@maggiolo00 Which config file are you referring to?

iamlogiq avatar Sep 03 '16 23:09 iamlogiq

hi @iamlogiq

see here

http://orientdb.com/docs/last/OrientJS-Server.html#using-tokens

wolf4ood avatar Sep 27 '16 15:09 wolf4ood