File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ module.exports = (autoInit = true) => {
8989 /** List of subscribed symbols */
9090 let subscribed = [ ] ;
9191
92+ /** Websockets status calls */
93+ let isEnded = false ;
94+
9295 /**
9396 * Send a custom packet
9497 * @param {string } t Packet type
@@ -184,9 +187,15 @@ module.exports = (autoInit = true) => {
184187
185188 /**
186189 * Close the websocket connection
187- * @param { string } symbol Market symbol (Example: BTCEUR or COINBASE:BTCEUR)
190+ * @return { Promise<void> } When websocket is closed
188191 */
189- end ( ) { ws . close ( ) ; } ,
192+ end ( ) {
193+ return new Promise ( ( cb ) => {
194+ isEnded = true ;
195+ ws . close ( ) ;
196+ cb ( ) ;
197+ } ) ;
198+ } ,
190199
191200 getUser,
192201 getChartToken,
@@ -290,6 +299,8 @@ module.exports = (autoInit = true) => {
290299 }
291300
292301 chartCBs [ chartSession ] = ( packet ) => {
302+ if ( isEnded ) return ;
303+
293304 if ( [ 'timescale_update' , 'du' ] . includes ( packet . type ) ) {
294305 updatePeriods ( packet ) ;
295306 onUpdate ( [ ...periods ] . reverse ( ) ) ;
You can’t perform that action at this time.
0 commit comments