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.
Execution environment
AWS Lambda Node (node v6.3)
Code sample
Description
When running this code sample, lambda function never ends because connection is not closed.
Then adding a
client.closeConnection()throws the following errorTypeError: 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()bythis.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.