7

I'm trying to use the gremlin npm module and connect to a Neptune database. During testing, I tried having gremlin connect to an inactive endpoint and invalid url to make the system more resilient. I expected some sort of error to be thrown. However, with invalid/inactive urls, graph traversals just don't resolve with no messaging.

        const traversal = gremlin.process.AnonymousTraversalSource.traversal;
        const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
        const dc = new DriverRemoteConnection('wss://localhost:80');
        const g = traversal().withRemote(dc);
        const data = await g.V().limit(1).toList();
        console.log(data);

I'd expect g.V().limit(1).toList() to throw an error when using an invalid remote connection. Again, the promise never resolves and the console.log(data) on the next line is never run.

Any help with this would be much appreciated! I need some sort of system to detect whether the database connection is valid and if not logs errors.

  • I tried using the Node (Javascript) client with a non existent host and an exception was thrown as soon as I tried to connect. Rather than using `localhost` what do you see if you use something that definitely does not resolve such as "abc123". Even using `localhost` I see a connection refused error. I it possible your code is somehow swallowing the exception? – Kelvin Lawrence May 31 '20 at 23:51
  • @KelvinLawrence Hi, thanks for you response! When I enter "abc123" an error is immediately thrown ```TypeError [ERR_INVALID_URL]: Invalid URL:```. However when I enter ```wss://localhost:8080``` I get no error or result. I'm capturing the exceptions and logging them with ```g.V().limit(1).toList().then(res => console.log(res)).catch(err=>console.log(err));``` – deterministic_ram Jun 01 '20 at 03:15
  • Is it possible you have something listening on that `localhost` port? When I try it on my system I get the `Error: connect ECONNREFUSED 127.0.0.1:8080` exception correctly thrown. – Kelvin Lawrence Jun 01 '20 at 17:28
  • @KelvinLawrence The weird thing is that when I ```curl -G https://localhost:8080/``` I get a connection error. Can I ask what version of Gremlin you are running? – deterministic_ram Jun 01 '20 at 18:26
  • Node.js 8.15 and Gremlin javascript 3.4.1 - I can try a later version also. – Kelvin Lawrence Jun 01 '20 at 20:35
  • @KelvinLawrence I switched to 3.4.1 and an error was thrown!!! It seems as though something breaks in newer versions. To your knowledge, is there any significant advantage of using the newer versions? – deterministic_ram Jun 02 '20 at 02:51
  • @KelvinLawrence I ran some tests and it looks like the errors aren't thrown in version 3.4.4 and up. – deterministic_ram Jun 02 '20 at 02:53
  • I also did some tests on 3.4.4 and do observe that it seems to swallow the errors. This probably needs additional investigation. – Kelvin Lawrence Jun 03 '20 at 00:43

1 Answers1

4

There is an issue in the current JavaScript GLV, we've filed TINKERPOP-2381 that summarizes the problems.

This should not affect the GLV when the address points to a valid server.

Thanks for providing so much detail in the question.


I'm adding an answer so that this thread is preserved.

After investigation if the host does not exist the 3.4.1 JavaScript Gremlin client throws an exception and exits the process. With the 3.4.4 client (or later) the error seems to get silently swallowed.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38