@exodus/market-history 10.2.1 → 10.2.2
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.
- package/CHANGELOG.md +6 -0
- package/module/index.js +39 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.2.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/market-history@10.2.1...@exodus/market-history@10.2.2) (2025-05-26)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix: potential race condition (#12678)
|
|
11
|
+
|
|
6
12
|
## [10.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/market-history@10.2.0...@exodus/market-history@10.2.1) (2025-05-18)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/module/index.js
CHANGED
|
@@ -148,7 +148,7 @@ class MarketHistoryMonitor {
|
|
|
148
148
|
this.#synchronizedTime = synchronizedTime
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
#
|
|
151
|
+
#isActive = false
|
|
152
152
|
|
|
153
153
|
#setCache = async ({ currency, granularity, pricesByAssetName }) => {
|
|
154
154
|
let hasChanges = false
|
|
@@ -272,7 +272,7 @@ class MarketHistoryMonitor {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
updateAll = async () => {
|
|
275
|
-
if (!this.#
|
|
275
|
+
if (!this.#isActive) {
|
|
276
276
|
const e = new Error('market-history updateAll cannot be called before module started')
|
|
277
277
|
this.#errorTracking.track({
|
|
278
278
|
error: e,
|
|
@@ -327,6 +327,10 @@ class MarketHistoryMonitor {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
#updateAssets = async (assetNames, granularities) => {
|
|
330
|
+
if (!this.#isActive) {
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
|
|
330
334
|
const currency = this.#currency
|
|
331
335
|
const promises = granularities.map((granularity) =>
|
|
332
336
|
this.#fetchPricesByGranularity({ granularity, assetNames, currency })
|
|
@@ -334,6 +338,10 @@ class MarketHistoryMonitor {
|
|
|
334
338
|
|
|
335
339
|
const results = await Promise.all(promises)
|
|
336
340
|
|
|
341
|
+
if (!this.#isActive) {
|
|
342
|
+
return
|
|
343
|
+
}
|
|
344
|
+
|
|
337
345
|
await this.#marketHistoryAtom.set((current) => {
|
|
338
346
|
const detectHasChanges = (result, parsedGranularity) => {
|
|
339
347
|
if (!current || !current.data) return true
|
|
@@ -399,6 +407,11 @@ class MarketHistoryMonitor {
|
|
|
399
407
|
difference(this.#remoteConfigClearCacheAtom).observe(({ current, previous }) => {
|
|
400
408
|
const clear = async () => {
|
|
401
409
|
await this.#invalidateStorage({ remoteConfigClearCacheVersion: current })
|
|
410
|
+
|
|
411
|
+
if (!this.#isActive) {
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
|
|
402
415
|
await this.updateAll()
|
|
403
416
|
}
|
|
404
417
|
|
|
@@ -459,6 +472,10 @@ class MarketHistoryMonitor {
|
|
|
459
472
|
},
|
|
460
473
|
}
|
|
461
474
|
})
|
|
475
|
+
if (!this.#isActive) {
|
|
476
|
+
return
|
|
477
|
+
}
|
|
478
|
+
|
|
462
479
|
this.updateAll()
|
|
463
480
|
}
|
|
464
481
|
})
|
|
@@ -497,39 +514,55 @@ class MarketHistoryMonitor {
|
|
|
497
514
|
|
|
498
515
|
start = makeConcurrent(
|
|
499
516
|
async () => {
|
|
500
|
-
if (this.#
|
|
517
|
+
if (this.#isActive) return
|
|
501
518
|
this.#logger.info('market history start')
|
|
502
|
-
this.#
|
|
519
|
+
this.#isActive = true
|
|
503
520
|
this.#abortController = new AbortController()
|
|
504
521
|
|
|
505
522
|
const remoteConfigClearCacheVersion = await this.#remoteConfigClearCacheAtom.get()
|
|
506
523
|
await this.#invalidateStorage({ remoteConfigClearCacheVersion })
|
|
507
524
|
|
|
525
|
+
if (!this.#isActive) {
|
|
526
|
+
return
|
|
527
|
+
}
|
|
528
|
+
|
|
508
529
|
this.#currency = await this.#currencyAtom.get()
|
|
509
530
|
this.#previouslyEnabledAssets = await this.#enabledAssetsAtom.get()
|
|
510
531
|
|
|
532
|
+
if (!this.#isActive) {
|
|
533
|
+
return
|
|
534
|
+
}
|
|
535
|
+
|
|
511
536
|
// Initialize atom if necessary
|
|
512
537
|
await this.#initMarketHistoryAtom()
|
|
513
538
|
|
|
539
|
+
if (!this.#isActive) {
|
|
540
|
+
return
|
|
541
|
+
}
|
|
542
|
+
|
|
514
543
|
this.#setupTimers()
|
|
515
544
|
this.#listenRemoteConfigClearCacheVersionChanges()
|
|
516
545
|
this.#listenCurrencyChanges()
|
|
517
546
|
this.#listenEnabledAssetsChanges()
|
|
518
547
|
|
|
548
|
+
if (!this.#isActive) {
|
|
549
|
+
return
|
|
550
|
+
}
|
|
551
|
+
|
|
519
552
|
await this.updateAll()
|
|
520
553
|
},
|
|
521
554
|
{ concurrency: 1 }
|
|
522
555
|
)
|
|
523
556
|
|
|
524
557
|
stop = () => {
|
|
525
|
-
if (!this.#
|
|
558
|
+
if (!this.#isActive) {
|
|
526
559
|
return
|
|
527
560
|
}
|
|
528
561
|
|
|
529
562
|
this.#logger.info('market history stops')
|
|
530
563
|
this.#atomListeners.forEach((unsubscribe) => unsubscribe())
|
|
531
564
|
this.#atomListeners = []
|
|
532
|
-
this.#
|
|
565
|
+
this.#isActive = false
|
|
533
566
|
this.#abortController.abort()
|
|
534
567
|
}
|
|
535
568
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/market-history",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "Fetches historical prices for assets",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@exodus/assets": "^11.0.0",
|
|
39
39
|
"@exodus/assets-base": "^10.0.0",
|
|
40
|
-
"@exodus/assets-feature": "^
|
|
40
|
+
"@exodus/assets-feature": "^8.1.1",
|
|
41
41
|
"@exodus/bitcoin-meta": "^2.0.0",
|
|
42
42
|
"@exodus/ethereum-meta": "^2.4.1",
|
|
43
43
|
"@exodus/locale": "^2.5.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c46def8fc6822d459f0a7c4cb00ac66fb5a2580c"
|
|
63
63
|
}
|