Skip to content

Error: this.connection.close is not a function #99

Description

@cyrilhamidechi

Execution environment
AWS Lambda Node (node v6.3)

Code sample

'use strict';

const gremlin = require('gremlin');

exports.handler = (event, context, callback) => {
  const client = gremlin.createClient(8182, "gizmo", { accept: "application/vnd.gremlin-v2.0+json" });
  client.execute('g.V().limit(2)', (err, results) => {
    console.log(err, results);
    callback(null, 'Hello from Lambda');
  });
};

Description
When running this code sample, lambda function never ends because connection is not closed.
Then adding a client.closeConnection() throws the following error TypeError: this.connection.close is not a function at GremlinClient.closeConnection (/var/task/node_modules/gremlin/lib/GremlinClient.js:119:21)

Fix
Adding directly client.connection.ws.close(); within the sample's callback makes the code sample work.
In the same manner, at https://github.com/jbmusso/gremlin-javascript/blob/master/gremlin-client/src/GremlinClient.js#L83, replacing this.connection.close() by this.connection.ws.close() makes also the code sample work (but I don't know if it follows well current coding project pattern).

Bonus
As a best practice, adding the close connection feature to documentation samples.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions