Using Gremlin client in Angular (TypeScript) app results in "crypto.randomBytes is not a function"

265 views
Skip to first unread message

Devin Bost

unread,
Jul 16, 2019, 7:15:31 PM7/16/19
to Gremlin-users
I am attempting to use the Gremlin client in an Angular app, and all I am attempting to do (so far) is create a simple connection and return some vertices, like this:

getVerticesTest() {
 
const traversal = gremlin.process.AnonymousTraversalSource.traversal;

 
const g = traversal().withRemote(
   
new DriverRemoteConnection('ws://localhost:8182/gremlin'));
 
const vertices = g.V().valueMap();
 
return vertices;
}

However, when I trigger this method, here's what happens:

CanvasComponent.html:5 ERROR TypeError: crypto.randomBytes is not a function
    at
WebSocket.initAsClient (WebSocket.js:541)
    at
new WebSocket (WebSocket.js:72)
    at
Connection.open (connection.js:120)
    at
new Connection (connection.js:102)
    at
new Client (client.js:47)
    at
new DriverRemoteConnection (driver-remote-connection.js:53)
    at
GremlinService.push../src/app/services/gremlin.service.ts.GremlinService.getVerticesTest (gremlin.service.ts:13)
    at
CanvasComponent.push../src/app/components/canvas/canvas.component.ts.CanvasComponent.onClickMe (canvas.component.ts:43)
    at
Object.eval [as handleEvent] (CanvasComponent.html:5)
    at handleEvent
(core.js:23107)

Does this library have outdated dependencies? How do I use it?

(BTW, I am fully aware that my method leaks memory. I will fix that once I can establish a basic connection.)

Stephen Mallette

unread,
Jul 17, 2019, 9:27:52 AM7/17/19
to gremli...@googlegroups.com
I'm not sure this is completely your problem but I don't think gremlin-javascript works too well with angular. someone started this PR to fix that but it was never quite completed unfortunately:




--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/d1f518e3-56dc-4acb-bb1d-b4d4d52a9dd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages