-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
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;
};