andreachild commented on code in PR #3204:
URL: https://github.com/apache/tinkerpop/pull/3204#discussion_r2342936149


##########
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/connection.ts:
##########
@@ -465,10 +469,14 @@ export default class Connection extends EventEmitter {
     this._ws?.removeEventListener('open', this.#handleOpen);
     // @ts-expect-error
     this._ws?.removeEventListener('error', this.#handleError);
-    // The following listener needs to use `.on` and `.off` because the `ws` 
package's addEventListener only accepts certain event types
-    // Ref: 
https://github.com/websockets/ws/blob/8.16.0/lib/event-target.js#L202-L241
-    // @ts-expect-error
-    this._ws?.off('unexpected-response', this.#handleUnexpectedResponse);
+    // Only remove unexpected-response listener for Node.js WebSocket (ws 
package)
+    // Browser WebSocket does not have this event and .off() method
+    if (this._ws && 'off' in this._ws) {

Review Comment:
   I am wondering if the same check as above `!useGlobalWebSocket` would also 
work here or is there a particular reason to use different if conditions for 
`.on` vs `.off`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to