@pioneer-platform/pioneer-cache 1.1.8 → 1.1.10
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/.turbo/turbo-build.log +2 -1
- package/CHANGELOG.md +17 -0
- package/dist/core/base-cache.js +11 -5
- package/dist/stores/balance-cache.js +15 -2
- package/package.json +1 -1
- package/src/core/base-cache.ts +8 -5
- package/src/stores/balance-cache.ts +15 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mtsc[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @pioneer-platform/pioneer-cache
|
|
2
2
|
|
|
3
|
+
## 1.1.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- chore: - This was causing production Pioneer API to return balances with empty CAIPs that would crash the vault on startup
|
|
8
|
+
|
|
9
|
+
## 1.1.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: Use requested caip/pubkey in cache placeholders instead of empty defaults
|
|
14
|
+
|
|
15
|
+
- When cache miss occurs, use the requested caip and pubkey in the placeholder response instead of empty strings
|
|
16
|
+
- Fixes issue where balance cache returned entries with empty caip/pubkey fields causing SDK crashes
|
|
17
|
+
- Affects getBatchBalances and getBalance methods
|
|
18
|
+
- This was causing production Pioneer API to return balances with empty CAIPs that would crash the vault on startup
|
|
19
|
+
|
|
3
20
|
## 1.1.8
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/core/base-cache.js
CHANGED
|
@@ -76,14 +76,17 @@ class BaseCache {
|
|
|
76
76
|
async get(params, waitForFresh) {
|
|
77
77
|
const tag = this.TAG + 'get | ';
|
|
78
78
|
const startTime = Date.now();
|
|
79
|
+
const shouldLogTiming = process.env.LOG_CACHE_TIMING === 'true' || process.env.NODE_ENV !== 'production';
|
|
79
80
|
try {
|
|
80
81
|
const t1 = Date.now();
|
|
81
82
|
const key = this.buildKey(params);
|
|
82
|
-
|
|
83
|
+
if (shouldLogTiming)
|
|
84
|
+
log.debug(tag, `⏱️ buildKey took ${Date.now() - t1}ms`);
|
|
83
85
|
// Step 1: Try new cache format
|
|
84
86
|
const t2 = Date.now();
|
|
85
87
|
const cachedValue = await this.getCached(key);
|
|
86
|
-
|
|
88
|
+
if (shouldLogTiming)
|
|
89
|
+
log.debug(tag, `⏱️ getCached took ${Date.now() - t2}ms`);
|
|
87
90
|
if (cachedValue) {
|
|
88
91
|
const age = Date.now() - cachedValue.timestamp;
|
|
89
92
|
const responseTime = Date.now() - startTime;
|
|
@@ -127,7 +130,8 @@ class BaseCache {
|
|
|
127
130
|
if (this.config.enableLegacyFallback) {
|
|
128
131
|
const t3 = Date.now();
|
|
129
132
|
const legacyValue = await this.getLegacyCached(params);
|
|
130
|
-
|
|
133
|
+
if (shouldLogTiming)
|
|
134
|
+
log.debug(tag, `⏱️ getLegacyCached took ${Date.now() - t3}ms`);
|
|
131
135
|
if (legacyValue) {
|
|
132
136
|
const responseTime = Date.now() - startTime;
|
|
133
137
|
log.info(tag, `Legacy cache hit: ${key} (${responseTime}ms)`);
|
|
@@ -163,8 +167,10 @@ class BaseCache {
|
|
|
163
167
|
// Non-blocking: trigger async refresh and return default
|
|
164
168
|
const t4 = Date.now();
|
|
165
169
|
this.triggerAsyncRefresh(params, 'high');
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
if (shouldLogTiming) {
|
|
171
|
+
log.debug(tag, `⏱️ triggerAsyncRefresh took ${Date.now() - t4}ms`);
|
|
172
|
+
log.debug(tag, `⏱️ Returning default value after ${Date.now() - startTime}ms TOTAL`);
|
|
173
|
+
}
|
|
168
174
|
return {
|
|
169
175
|
success: true,
|
|
170
176
|
value: this.config.defaultValue,
|
|
@@ -200,7 +200,13 @@ class BalanceCache extends base_cache_1.BaseCache {
|
|
|
200
200
|
*/
|
|
201
201
|
async getBalance(caip, pubkey, waitForFresh) {
|
|
202
202
|
const result = await this.get({ caip, pubkey }, waitForFresh);
|
|
203
|
-
return result.value ||
|
|
203
|
+
return result.value || {
|
|
204
|
+
caip,
|
|
205
|
+
pubkey,
|
|
206
|
+
balance: '0',
|
|
207
|
+
fetchedAt: Date.now(),
|
|
208
|
+
fetchedAtISO: new Date().toISOString()
|
|
209
|
+
};
|
|
204
210
|
}
|
|
205
211
|
/**
|
|
206
212
|
* Get balances for multiple assets (batch operation)
|
|
@@ -266,7 +272,14 @@ class BalanceCache extends base_cache_1.BaseCache {
|
|
|
266
272
|
}
|
|
267
273
|
// Cache miss - record for fetching
|
|
268
274
|
missedItems.push({ ...item, index: i });
|
|
269
|
-
|
|
275
|
+
// Use requested caip/pubkey in placeholder, not empty defaults
|
|
276
|
+
results[i] = {
|
|
277
|
+
caip: item.caip,
|
|
278
|
+
pubkey: item.pubkey,
|
|
279
|
+
balance: '0',
|
|
280
|
+
fetchedAt: Date.now(),
|
|
281
|
+
fetchedAtISO: new Date().toISOString()
|
|
282
|
+
};
|
|
270
283
|
}
|
|
271
284
|
const responseTime = Date.now() - startTime;
|
|
272
285
|
const hitRate = ((items.length - missedItems.length) / items.length * 100).toFixed(1);
|
package/package.json
CHANGED
package/src/core/base-cache.ts
CHANGED
|
@@ -96,16 +96,17 @@ export abstract class BaseCache<T> {
|
|
|
96
96
|
async get(params: Record<string, any>, waitForFresh?: boolean): Promise<CacheResult<T>> {
|
|
97
97
|
const tag = this.TAG + 'get | ';
|
|
98
98
|
const startTime = Date.now();
|
|
99
|
+
const shouldLogTiming = process.env.LOG_CACHE_TIMING === 'true' || process.env.NODE_ENV !== 'production';
|
|
99
100
|
|
|
100
101
|
try {
|
|
101
102
|
const t1 = Date.now();
|
|
102
103
|
const key = this.buildKey(params);
|
|
103
|
-
log.
|
|
104
|
+
if (shouldLogTiming) log.debug(tag, `⏱️ buildKey took ${Date.now() - t1}ms`);
|
|
104
105
|
|
|
105
106
|
// Step 1: Try new cache format
|
|
106
107
|
const t2 = Date.now();
|
|
107
108
|
const cachedValue = await this.getCached(key);
|
|
108
|
-
log.
|
|
109
|
+
if (shouldLogTiming) log.debug(tag, `⏱️ getCached took ${Date.now() - t2}ms`);
|
|
109
110
|
|
|
110
111
|
if (cachedValue) {
|
|
111
112
|
const age = Date.now() - cachedValue.timestamp;
|
|
@@ -159,7 +160,7 @@ export abstract class BaseCache<T> {
|
|
|
159
160
|
if (this.config.enableLegacyFallback) {
|
|
160
161
|
const t3 = Date.now();
|
|
161
162
|
const legacyValue = await this.getLegacyCached(params);
|
|
162
|
-
log.
|
|
163
|
+
if (shouldLogTiming) log.debug(tag, `⏱️ getLegacyCached took ${Date.now() - t3}ms`);
|
|
163
164
|
if (legacyValue) {
|
|
164
165
|
const responseTime = Date.now() - startTime;
|
|
165
166
|
log.info(tag, `Legacy cache hit: ${key} (${responseTime}ms)`);
|
|
@@ -200,8 +201,10 @@ export abstract class BaseCache<T> {
|
|
|
200
201
|
// Non-blocking: trigger async refresh and return default
|
|
201
202
|
const t4 = Date.now();
|
|
202
203
|
this.triggerAsyncRefresh(params, 'high');
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
if (shouldLogTiming) {
|
|
205
|
+
log.debug(tag, `⏱️ triggerAsyncRefresh took ${Date.now() - t4}ms`);
|
|
206
|
+
log.debug(tag, `⏱️ Returning default value after ${Date.now() - startTime}ms TOTAL`);
|
|
207
|
+
}
|
|
205
208
|
|
|
206
209
|
return {
|
|
207
210
|
success: true,
|
|
@@ -239,7 +239,13 @@ export class BalanceCache extends BaseCache<BalanceData> {
|
|
|
239
239
|
*/
|
|
240
240
|
async getBalance(caip: string, pubkey: string, waitForFresh?: boolean): Promise<BalanceData> {
|
|
241
241
|
const result = await this.get({ caip, pubkey }, waitForFresh);
|
|
242
|
-
return result.value ||
|
|
242
|
+
return result.value || {
|
|
243
|
+
caip,
|
|
244
|
+
pubkey,
|
|
245
|
+
balance: '0',
|
|
246
|
+
fetchedAt: Date.now(),
|
|
247
|
+
fetchedAtISO: new Date().toISOString()
|
|
248
|
+
};
|
|
243
249
|
}
|
|
244
250
|
|
|
245
251
|
/**
|
|
@@ -314,7 +320,14 @@ export class BalanceCache extends BaseCache<BalanceData> {
|
|
|
314
320
|
|
|
315
321
|
// Cache miss - record for fetching
|
|
316
322
|
missedItems.push({ ...item, index: i });
|
|
317
|
-
|
|
323
|
+
// Use requested caip/pubkey in placeholder, not empty defaults
|
|
324
|
+
results[i] = {
|
|
325
|
+
caip: item.caip,
|
|
326
|
+
pubkey: item.pubkey,
|
|
327
|
+
balance: '0',
|
|
328
|
+
fetchedAt: Date.now(),
|
|
329
|
+
fetchedAtISO: new Date().toISOString()
|
|
330
|
+
};
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
const responseTime = Date.now() - startTime;
|