Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 015c5db

Browse files
committed
Handled websocket disconnection error before connection established
1 parent 4d9fbe0 commit 015c5db

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/botPage/bot/Interpreter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ export default class Interpreter {
163163
this.loop();
164164
}
165165
terminateSession() {
166-
this.$scope.api.disconnect();
166+
const { socket } = this.$scope.api;
167+
if (socket.readyState === 0) {
168+
socket.addEventListener('open', () => {
169+
this.$scope.api.disconnect();
170+
});
171+
} else if (socket.readyState === 1) {
172+
this.$scope.api.disconnect();
173+
}
167174
this.stopped = true;
168175

169176
globalObserver.emit('bot.stop');

0 commit comments

Comments
 (0)