@@ -226,8 +226,13 @@ export class RealtimeController extends BaseController {
226226 * Called when kuzzle is disconnected
227227 */
228228 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 ) {
231236 room . removeListeners ( ) ;
232237
233238 if ( room . autoResubscribe ) {
@@ -239,15 +244,20 @@ export class RealtimeController extends BaseController {
239244 }
240245
241246 this . _subscriptions . delete ( roomId ) ;
242- }
247+
248+ } ) ;
243249 }
244250
245251 /**
246252 * Called on kuzzle reconnection
247253 */
248254 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 ) {
251261 if ( ! this . _subscriptions . has ( roomId ) ) {
252262 this . _subscriptions . set ( roomId , [ ] ) ;
253263 }
@@ -258,18 +268,22 @@ export class RealtimeController extends BaseController {
258268 }
259269
260270 this . _subscriptionsOff . delete ( roomId ) ;
261- }
271+ } ) ;
262272 }
263273
264274 /**
265275 * Called when a token expire
266276 */
267277 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 ) {
270284 room . removeListeners ( ) ;
271285 }
272- }
286+ } ) ;
273287
274288 this . _subscriptions = new Map ( ) ;
275289 this . _subscriptionsOff = new Map ( ) ;
0 commit comments