Gremlin-JavaScript Global Websocket

I’m just wondering if there is a reason the gremlin-JavaScript 3.7 branch does not pass options/headers to the globalThis.WebSocket if defined?
3 Replies
Kennh
Kennh2w ago
I think you are referring to https://github.com/apache/tinkerpop/blob/3.7-dev/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/connection.js#L141 To the best of my knowledge, it's because the constructor for WebSocket is different depending if you are running on Node.js or the browser. With Node the ws library accepts those extra options but the standard globalThis.WebSocket doesn't. There doesn't seem to many options to configure the globalThis.WebSocket. Is there something that you think is missing? It can definitely be added if it helps to create more parity between the browser/Node implementations.
GitHub
tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript...
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
Kyle
KyleOP2w ago
I believe my team has hit an issue with Node 22 (which includes a globalThis.Websocket) and our implementation of the connection to AWS Neptune due to the fact that the headers are not passed/included with the globalThis.WebSocket. I do see the MDN docs about WebSocket in the browser not having those options, whereas NodeJS does. For my use case connecting to Neptune, we NEED the headers set. I wonder if that ternary statement could be tweaked to only use globalThis.WebSocket if we are running in the browser and NO additional options, like headers, ca, etc, are present. At least some kind of check for support of the options in the WebSocket.
Kyle
KyleOP2w ago
Here is my attempt at solving this: https://github.com/apache/tinkerpop/pull/2968
GitHub
Use ws WebSocket when options are provided by KyleBoyer · Pull Re...
The current 3.7-dev implementation does not pass headers to the WebSocket when utilizing the globalThis.WebSocket. This causes issues when initially upgrading to this version of gremlin (or upgradi...

Did you find this page helpful?