@@ -226,8 +226,13 @@ export class RealtimeController extends BaseController {
226
226
* Called when kuzzle is disconnected
227
227
*/
228
228
private saveSubscriptions ( ) {
229
- for ( const roomId of this . _subscriptions . keys ( ) ) {
230
- for ( const room of this . _subscriptions . get ( roomId ) ) {
229
+ /**
230
+ * Use forEach instead of iterating over Map.keys() because the Webpack
231
+ * transpilation is producing bad code leading to a loop not iterating.
232
+ */
233
+ this . _subscriptions . forEach ( ( rooms , roomId ) => {
234
+
235
+ for ( const room of rooms ) {
231
236
room . removeListeners ( ) ;
232
237
233
238
if ( room . autoResubscribe ) {
@@ -239,15 +244,20 @@ export class RealtimeController extends BaseController {
239
244
}
240
245
241
246
this . _subscriptions . delete ( roomId ) ;
242
- }
247
+
248
+ } ) ;
243
249
}
244
250
245
251
/**
246
252
* Called on kuzzle reconnection
247
253
*/
248
254
private resubscribe ( ) {
249
- for ( const roomId of this . _subscriptionsOff . keys ( ) ) {
250
- for ( const room of this . _subscriptionsOff . get ( roomId ) ) {
255
+ /**
256
+ * Use forEach instead of iterating over Map.keys() because the Webpack
257
+ * transpilation is producing bad code leading to a loop not iterating.
258
+ */
259
+ this . _subscriptionsOff . forEach ( ( rooms , roomId ) => {
260
+ for ( const room of rooms ) {
251
261
if ( ! this . _subscriptions . has ( roomId ) ) {
252
262
this . _subscriptions . set ( roomId , [ ] ) ;
253
263
}
@@ -258,18 +268,22 @@ export class RealtimeController extends BaseController {
258
268
}
259
269
260
270
this . _subscriptionsOff . delete ( roomId ) ;
261
- }
271
+ } ) ;
262
272
}
263
273
264
274
/**
265
275
* Called when a token expire
266
276
*/
267
277
private removeSubscriptions ( ) {
268
- for ( const roomId of this . _subscriptions . keys ( ) ) {
269
- for ( const room of this . _subscriptions . get ( roomId ) ) {
278
+ /**
279
+ * Use forEach instead of iterating over Map.keys() because the Webpack
280
+ * transpilation is producing bad code leading to a loop not iterating.
281
+ */
282
+ this . _subscriptions . forEach ( ( rooms ) => {
283
+ for ( const room of rooms ) {
270
284
room . removeListeners ( ) ;
271
285
}
272
- }
286
+ } ) ;
273
287
274
288
this . _subscriptions = new Map ( ) ;
275
289
this . _subscriptionsOff = new Map ( ) ;
0 commit comments