@icgio/icg-exchanges-wrapper 1.17.25 → 1.17.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -162,9 +162,6 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
162
162
|
return
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
// Store promise before starting connection
|
|
166
|
-
ws_connection_promises[ws_key] = ws_promise
|
|
167
|
-
|
|
168
165
|
// Create WebSocket with ALL pairs collected in first pass
|
|
169
166
|
// This ensures only ONE WebSocket per exchange, even with multiple clients/pairs
|
|
170
167
|
Exchange.ws_market(all_pairs)
|
|
@@ -308,9 +305,12 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
308
305
|
|
|
309
306
|
check_status()
|
|
310
307
|
})
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
//
|
|
308
|
+
// Store the cached promise AFTER `new Promise(...)` returns — assigning inside
|
|
309
|
+
// the synchronous executor reads the outer binding while it's still undefined.
|
|
310
|
+
// Keep the entry alive while the socket is alive; the next tick's
|
|
311
|
+
// `is_opening_or_opened` check reads `Exchange.ws.market.status` and the
|
|
312
|
+
// else-branch above overwrites this slot when the socket is closed/stopped.
|
|
313
|
+
ws_connection_promises[ws_key] = ws_promise
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// Wrap WebSocket promise to handle rejection and fall back to REST
|
|
@@ -435,9 +435,6 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
|
|
|
435
435
|
return
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
// Store promise before starting connection
|
|
439
|
-
ws_market_history_promises[ws_key] = ws_promise
|
|
440
|
-
|
|
441
438
|
// Only start if not already started (reuse connection from rates if available)
|
|
442
439
|
// If starting new, use ALL pairs collected in first pass
|
|
443
440
|
if (!first_time[Exchange_name]) {
|
|
@@ -579,9 +576,11 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
|
|
|
579
576
|
}
|
|
580
577
|
check_status()
|
|
581
578
|
})
|
|
582
|
-
//
|
|
583
|
-
//
|
|
584
|
-
//
|
|
579
|
+
// Store the cached promise AFTER `new Promise(...)` returns — assigning inside
|
|
580
|
+
// the synchronous executor reads the outer binding while it's still undefined.
|
|
581
|
+
// Keep the entry alive while the socket is alive; the else-branch above
|
|
582
|
+
// overwrites this slot when the socket is closed/stopped.
|
|
583
|
+
ws_market_history_promises[ws_key] = ws_promise
|
|
585
584
|
}
|
|
586
585
|
|
|
587
586
|
// If WebSocket promise rejects (timeout/error), fall back to REST for all pairs
|