Search code examples
gremlinamazon-neptune

Issue with .project().by() in Gremlin JS 3.4.0


I'm seeing .project().by() traversals returning {} under Gremlin JS 3.4.0. When I downgrade to 3.2.10 they work correctly.

gremlin> g.addV("trip").property(single, "trackName", "Ohio")

==>v[1]

In Gremlin JS `3.4.0`:

const result = await g.V("1").project("trackName").by("trackName").next();

result:

{
  "value": {},
  "done": false
}

but when I downgrade to Gremlin 3.2.10 the result is correct:

{
  "value": {
    "trackName": "Ohio"
  },
  "done": false
}

Do I need to change how I use project in 3.4.0?

EDIT: Results from testing against different versions. I ran each test for a gremlin version, captured results, then bumped up the version and ran the tests again. I am only running a single Neptune instance so we can be sure this is the same data.

enter image description here

A failing test means it returned data in the form of:

"results": {
 "value": {},
 "done": false
}

For the console testing I removed the final .next().

The environment I am testing in is:

AWS Lambda Node 8.10

AWS Neptune 1.0.1.0

EDIT 2: Adding JS files used during Neptune test.

index.js

const gremlin = require("gremlin");

const { DriverRemoteConnection } = gremlin.driver;
const { Graph } = gremlin.structure;

const initGremlinClient = () => {
  try {
    const dc = new DriverRemoteConnection(
      `ws://my-cluster.XXXXXXX.us-east-1.neptune.amazonaws.com:8182/gremlin`,
      {}
    );
    const graph = new Graph();
    return {
      g: graph.traversal().withRemote(dc),
      closeGremlinConnection: () => dc.close()
    };
  } catch (error) {
    console.log("[GREMLIN INIT ERROR]", error);
    throw new Error(error);
  }
};

exports.handler = async event => {
  const { g, closeGremlinConnection } = initGremlinClient();

  const result = await g
    .addV("test")
    .property("myProp", "myValue")
    .project("myProp")
    .by("myProp")
    .next();
  closeGremlinConnection();
  return result;
};

package.json

{
  "name": "gremlinTest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "gremlin": "3.4.0"
  }
}

Solution

  • I spoke with someone on the AWS team. There is a bug affecting interoperability between Gremlin ^3.3.5 and Lambda. Specifically, the issue is with the underlying GraphSON v3 engine and how Lambda parses JSON.

    The temporary workaround is to fall back to GraphSON v2 when instantiating DriverRemoteConnection:

    const dc = new DriverRemoteConnection(
      `ws://my-neptune-cluster.us-east-1.neptune.amazonaws.com:8182/gremlin`,
      { mimeType: "application/vnd.gremlin-v2.0+json" } // Fall back to GraphSON v2
    );
    

    Edit: This issue still exists as of gremlin@3.4.6.