Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _a.terminate is not a function #305

Closed
hirenreshamwala opened this issue Dec 20, 2023 · 2 comments
Closed

TypeError: _a.terminate is not a function #305

hirenreshamwala opened this issue Dec 20, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hirenreshamwala
Copy link

I am using this library in browser. I am getting following error sometimes.

TypeError: _a.terminate is not a function
Call Stack
executeReconnectableClose
node_modules/bybit-api/lib/websocket-client.js (511:0)
<unknown>
node_modules/bybit-api/lib/websocket-client.js (500:0)

Here is what on in websocket-client.js

506     executeReconnectableClose(wsKey, reason) {
507         var _a;
508         this.logger.info(`${reason} - closing socket to reconnect`, Object.assign(Object.assign({}, loggerCategory), { wsKey,
509             reason }));
510         const wasOpen = this.wsStore.isWsOpen(wsKey);
511         (_a = this.getWs(wsKey)) === null || _a === void 0 ? void 0 : _a.terminate();
512         delete this.wsStore.get(wsKey, true).activePongTimer;
513         this.clearPingTimer(wsKey);
514         this.clearPongTimer(wsKey);
515         if (!wasOpen) {
516             this.logger.info(`${reason} - socket already closed - trigger immediate reconnect`, Object.assign(Object.assign({}, loggerCategory), { wsKey,
517                 reason }));
518             this.reconnectWithDelay(wsKey, this.options.reconnectTimeout);
519         }
520     }

Please provide the solution for this issue.

tiagosiebler pushed a commit that referenced this issue Dec 22, 2023
@tiagosiebler
Copy link
Owner

Looks like the websocket terminate() functionality does not exist in browsers, only in nodejs. I'm making improvements so it doesn't throw an exception in browsers (see PR #306). I'm expecting the executeReconnectableClose to still work once my changes are done, since there's also a websocket.close() call which should work in browsers too.

@tiagosiebler tiagosiebler added the bug Something isn't working label Dec 22, 2023
@tiagosiebler
Copy link
Owner

Fixed in v3.8.0. Let me know if there's anything else missing - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants