Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cyrilhamidechi opened this issue Jan 9, 2018 · 0 comments
Open

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

cyrilhamidechi opened this issue Jan 9, 2018 · 0 comments

Comments

@cyrilhamidechi
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant