gremlin-javascript icon indicating copy to clipboard operation
gremlin-javascript copied to clipboard

Cannot read property 'messageStream' of undefined, and Invalid OpProcessor requested [null]

Open davidcrouch opened this issue 9 years ago • 4 comments

Hi,

I'm running a batch of traversals (about 50-60) and I'm getting the error below. Unfortunately, the error is not easy to reproduce but it does occur in the same module. Secondly, if I add console log messages or increase the debug levels, or step through the code, the error goes away. So, I'm limited on what I can provide to reproduce the problem. Any ideas on what it could be?

Thanks, Dave

Log from the client:-

2016-11-21T07:00:24.857Z - error: uncaughtException: Cannot read property 'messageStream' of undefined date=Sun Nov 20 2016 23:00:24 GMT-0800 (Pacific Standard Time), pid=13136, uid=null, gid=null, cwd=D:\itc\development\itc\itc-dev\node_modules\applications\apps\my-home-space\init, execPath=D:\nodejs\node.exe, version=v6.6.0, argv=[D:\nodejs\node.exe, D:\itc\development\itc\itc-dev\node_modules\applications\apps\my-home-space\init\init-everything.js], rss=73846784, heapTotal=65933312, heapUsed=35439928, loadavg=[0, 0, 0], uptime=1050133.7672195 TypeError: Cannot read property 'messageStream' of undefined at GremlinClient.handleProtocolMessage (D:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:153:51) at WebSocketGremlinConnection.<anonymous> (D:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:120:23) at emitOne (events.js:96:13) at WebSocketGremlinConnection.emit (events.js:188:7) at WebSocketGremlinConnection.handleMessage (D:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:69:12) at WebSocketGremlinConnection._this.ws.onmessage (D:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:46:20) at WebSocket.onMessage (D:\itc\development\itc\node_modules\ws\lib\WebSocket.js:418:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at Receiver.onbinary (D:\itc\development\itc\node_modules\ws\lib\WebSocket.js:823:10)

Log from the Gremlin server:-

22:57:22 [WARN] AbstractGraphSONMessageSerializerV1d0.deserializeRequest:147 - Request [PooledUnsafeDirectByteBuf(ridx: 373, widx: 373, cap: 390)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0. 22:57:22 [WARN] OpSelectorHandler.decode:88 - Invalid OpProcessor requested [null] org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null] at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:84) at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) at java.lang.Thread.run(Unknown Source)

davidcrouch avatar Nov 21 '16 07:11 davidcrouch

Some more info. I was able to capture a script that is causing the error. "runAs" is a custom step.

debug: gremlin-client.execute: script: g.runAs(user_token).V(69621).out('Libraries').has('Name', 'My Home Space Library').out('Categories').has('Name', 'Catalogs').valueMap(true) , params: user_token=62740.wh9FfefSL4YN+d9dZq72NN7tL3bvxnwyxlMYbGRk4hM

davidcrouch avatar Nov 21 '16 07:11 davidcrouch

Got the same problems here on a v6.3.0 node application. It comes from several gremlin scripts I can't list there.

The fun thing here is that the same package at the same version causes no crash with a v5.10.1 node application.

dragma avatar Jan 18 '17 11:01 dragma

I ran into this issue as well and think I was able to find a root cause. The gremlin server I was using would sometimes send multiple responses for a single request, causing the client to throw the Cannot read property 'messageStream' of undefined error.

The problem appears to be that upon receiving the first response for the request, the stream for that request gets cleared out and then the lookup fails when a subsequent request is sent. A simple null check should be enough to fix it.

princjef avatar Mar 10 '17 00:03 princjef

I went through the same issue using CosmosDB from Azure and what I did to remedy the error is as follows:

under lib/GremlinClient.js line 160 I added the following

if(this.commands[requestId] != undefined)
      var messageStream = this.commands[requestId].messageStream;
else {
	var messageStream = [];
	statusCode = 204
}

I tried to put return but the process would exit, am inserting 65K transactions, so I needed the process to continue running after the error happens, not sure if this would be the best thing to do but it worked

abdullahshahin avatar Jun 11 '17 20:06 abdullahshahin