Skip to content

Commit 6b9e36b

Browse files
committed
correct socket creation logic
1 parent 52ebd70 commit 6b9e36b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.webpack/webpack.prod.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ const path = require('path');
1111

1212
/** @type {import('webpack').Configuration} */
1313
module.exports = merge(common, {
14-
mode: 'production',
15-
devtool: 'eval-source-map'
14+
mode: 'production'
1615
});

src/realtime/MCWSStreamWorkerScript.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,20 @@
154154

155155
// no subscribers or no topic close existing socket
156156
// suppress errors as they are not useful
157-
if (oldSocket && (Object.keys(subscribers).length < 1 || !this.topic)) {
158-
try {
159-
oldSocket.onclose = null;
160-
oldSocket.onerror = null;
161-
oldSocket.close();
162-
} catch (e) {
163-
// Suppress errors
157+
if (Object.keys(subscribers).length < 1 || !this.topic) {
158+
if (oldSocket) {
159+
try {
160+
oldSocket.onclose = null;
161+
oldSocket.onerror = null;
162+
oldSocket.close();
163+
} catch (e) {
164+
// Suppress errors
165+
}
166+
167+
oldSocket = undefined;
168+
this.socket = undefined;
164169
}
165170

166-
oldSocket = undefined;
167-
this.socket = undefined;
168171
return;
169172
}
170173

0 commit comments

Comments
 (0)