@pioneer-platform/pioneer-cache 1.28.11 → 1.28.13

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @pioneer-platform/pioneer-cache@1.28.11 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/pioneer/pioneer-cache
3
+ > @pioneer-platform/pioneer-cache@1.28.13 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/pioneer/pioneer-cache
4
4
  > tsc
5
5
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @pioneer-platform/pioneer-cache
2
2
 
3
+ ## 1.28.13
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: Redis gzip binary corruption in tx history + SDK transaction loading from vault cache
8
+ - Updated dependencies
9
+ - @pioneer-platform/pioneer-discovery@8.51.13
10
+ - @pioneer-platform/pioneer-caip@9.27.8
11
+ - @pioneer-platform/default-redis@8.11.9
12
+ - @pioneer-platform/redis-queue@8.12.19
13
+
14
+ ## 1.28.12
15
+
16
+ ### Patch Changes
17
+
18
+ - chore: fix: dashboard staleness uses newest fetchedAt instead of oldest
19
+ - Updated dependencies
20
+ - @pioneer-platform/pioneer-discovery@8.51.12
21
+ - @pioneer-platform/pioneer-caip@9.27.7
22
+ - @pioneer-platform/default-redis@8.11.8
23
+ - @pioneer-platform/redis-queue@8.12.18
24
+
3
25
  ## 1.28.11
4
26
 
5
27
  ### Patch Changes
@@ -30,8 +30,9 @@ export declare class RefreshWorker {
30
30
  */
31
31
  start(): Promise<void>;
32
32
  /**
33
- * Purge stale jobs from queue on startup
34
- * Scans queue and removes jobs older than 1 hour
33
+ * Purge all jobs from queue on startup
34
+ * On restart, all old jobs are stale nuke the queue entirely.
35
+ * Fresh refresh jobs will be created organically as new requests come in.
35
36
  */
36
37
  private purgeStaleJobsOnStartup;
37
38
  /**
@@ -51,6 +52,10 @@ export declare class RefreshWorker {
51
52
  * Process a single refresh job
52
53
  */
53
54
  private processJob;
55
+ /**
56
+ * Purge the entire queue — drop all pending jobs immediately
57
+ */
58
+ purgeQueue(): Promise<number>;
54
59
  /**
55
60
  * Get worker statistics
56
61
  */
@@ -56,57 +56,24 @@ class RefreshWorker {
56
56
  log.info(tag, '✅ Refresh worker started successfully');
57
57
  }
58
58
  /**
59
- * Purge stale jobs from queue on startup
60
- * Scans queue and removes jobs older than 1 hour
59
+ * Purge all jobs from queue on startup
60
+ * On restart, all old jobs are stale nuke the queue entirely.
61
+ * Fresh refresh jobs will be created organically as new requests come in.
61
62
  */
62
63
  async purgeStaleJobsOnStartup() {
63
64
  const tag = TAG + 'purgeStaleJobsOnStartup | ';
64
65
  try {
65
- const MAX_JOB_AGE_MS = 60 * 60 * 1000; // 1 hour
66
- const now = Date.now();
67
- let purgedCount = 0;
68
- let scannedCount = 0;
69
- log.info(tag, `Scanning queue for stale jobs (age > ${MAX_JOB_AGE_MS / 1000}s)...`);
70
- // Get queue length
71
66
  const queueLength = await this.redisQueue.count(this.config.queueName);
72
67
  if (queueLength === 0) {
73
- log.info(tag, '✅ Queue is empty, no stale jobs to purge');
68
+ log.info(tag, '✅ Queue is empty, nothing to purge');
74
69
  return;
75
70
  }
76
- log.info(tag, `Found ${queueLength} jobs in queue, checking for stale jobs...`);
77
- // Scan up to 100 jobs to find stale ones
78
- const MAX_SCAN = Math.min(queueLength, 100);
79
- const tempJobs = [];
80
- for (let i = 0; i < MAX_SCAN; i++) {
81
- const job = await this.redisQueue.getWork(this.config.queueName, 1);
82
- if (!job)
83
- break;
84
- scannedCount++;
85
- const jobTimestamp = job.timestamp || 0;
86
- const jobAge = jobTimestamp > 0 ? now - jobTimestamp : 0;
87
- if (jobAge > MAX_JOB_AGE_MS) {
88
- purgedCount++;
89
- log.warn(tag, ` Purged stale job: ${job.type} (age: ${Math.round(jobAge / 1000)}s)`);
90
- }
91
- else {
92
- // Keep fresh jobs - we'll re-queue them
93
- tempJobs.push(job);
94
- }
95
- }
96
- // Re-queue fresh jobs
97
- for (const job of tempJobs) {
98
- await this.redisQueue.createWork(this.config.queueName, job);
99
- }
100
- if (purgedCount > 0) {
101
- log.info(tag, `✅ Purged ${purgedCount} stale jobs (scanned ${scannedCount})`);
102
- }
103
- else {
104
- log.info(tag, `✅ No stale jobs found (scanned ${scannedCount})`);
105
- }
71
+ // Nuclear purge delete the entire Redis list
72
+ await this.redisQueue.delete(this.config.queueName);
73
+ log.info(tag, `✅ Purged entire queue on startup: ${queueLength} stale jobs dropped from "${this.config.queueName}"`);
106
74
  }
107
75
  catch (error) {
108
76
  log.error(tag, '⚠️ Error during startup purge (non-fatal):', error);
109
- // Don't throw - startup purge failure shouldn't prevent worker from starting
110
77
  }
111
78
  }
112
79
  /**
@@ -193,9 +160,7 @@ class RefreshWorker {
193
160
  if (jobTimestamp > 0) {
194
161
  const actualJobAge = Date.now() - jobTimestamp;
195
162
  if (actualJobAge > MAX_JOB_AGE_MS) {
196
- log.error(tag, `⚠️ DROPPING STALE JOB: ${type} (age: ${Math.round(actualJobAge / 1000)}s, max: ${MAX_JOB_AGE_MS / 1000}s)`);
197
- log.error(tag, ` Job key: ${key}`);
198
- log.error(tag, ` Job has been removed from queue and will not be retried`);
163
+ log.warn(tag, `Dropped stale ${type} job (age: ${Math.round(actualJobAge / 1000)}s): ${key}`);
199
164
  return;
200
165
  }
201
166
  }
@@ -203,13 +168,8 @@ class RefreshWorker {
203
168
  const cacheName = type.replace('REFRESH_', '').toLowerCase();
204
169
  // Get the appropriate cache instance
205
170
  const cache = this.cacheRegistry.get(cacheName);
206
- // FIX #2: Drop unsupported job types with clear error message
207
171
  if (!cache) {
208
- log.error(tag, `❌ DROPPING UNSUPPORTED JOB: ${type}`);
209
- log.error(tag, ` Cache type "${cacheName}" is not registered in this worker`);
210
- log.error(tag, ` Registered caches: ${Array.from(this.cacheRegistry.keys()).join(', ') || 'NONE'}`);
211
- log.error(tag, ` Job key: ${key}`);
212
- log.error(tag, ` Job has been removed from queue and will not be retried`);
172
+ log.warn(tag, `Dropped unsupported ${type} job (no "${cacheName}" cache registered): ${key}`);
213
173
  return;
214
174
  }
215
175
  // Fetch fresh data using the cache's fetchFresh method
@@ -254,6 +214,18 @@ class RefreshWorker {
254
214
  throw error;
255
215
  }
256
216
  }
217
+ /**
218
+ * Purge the entire queue — drop all pending jobs immediately
219
+ */
220
+ async purgeQueue() {
221
+ const tag = TAG + 'purgeQueue | ';
222
+ const count = await this.redisQueue.count(this.config.queueName);
223
+ if (count > 0) {
224
+ await this.redisQueue.delete(this.config.queueName);
225
+ log.info(tag, `✅ Purged ${count} jobs from "${this.config.queueName}"`);
226
+ }
227
+ return count;
228
+ }
257
229
  /**
258
230
  * Get worker statistics
259
231
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/pioneer-cache",
3
- "version": "1.28.11",
3
+ "version": "1.28.13",
4
4
  "description": "Unified caching system for Pioneer platform with Redis backend",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,11 +14,11 @@
14
14
  "author": "Pioneer Platform",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
+ "@pioneer-platform/default-redis": "8.11.9",
17
18
  "@pioneer-platform/loggerdog": "8.11.0",
18
- "@pioneer-platform/redis-queue": "8.12.17",
19
- "@pioneer-platform/pioneer-discovery": "8.51.11",
20
- "@pioneer-platform/pioneer-caip": "9.27.6",
21
- "@pioneer-platform/default-redis": "8.11.7"
19
+ "@pioneer-platform/redis-queue": "8.12.19",
20
+ "@pioneer-platform/pioneer-discovery": "8.51.13",
21
+ "@pioneer-platform/pioneer-caip": "9.27.8"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/jest": "^29.5.0",
@@ -79,66 +79,27 @@ export class RefreshWorker {
79
79
  }
80
80
 
81
81
  /**
82
- * Purge stale jobs from queue on startup
83
- * Scans queue and removes jobs older than 1 hour
82
+ * Purge all jobs from queue on startup
83
+ * On restart, all old jobs are stale nuke the queue entirely.
84
+ * Fresh refresh jobs will be created organically as new requests come in.
84
85
  */
85
86
  private async purgeStaleJobsOnStartup(): Promise<void> {
86
87
  const tag = TAG + 'purgeStaleJobsOnStartup | ';
87
88
 
88
89
  try {
89
- const MAX_JOB_AGE_MS = 60 * 60 * 1000; // 1 hour
90
- const now = Date.now();
91
- let purgedCount = 0;
92
- let scannedCount = 0;
93
-
94
- log.info(tag, `Scanning queue for stale jobs (age > ${MAX_JOB_AGE_MS / 1000}s)...`);
95
-
96
- // Get queue length
97
90
  const queueLength = await this.redisQueue.count(this.config.queueName);
98
91
 
99
92
  if (queueLength === 0) {
100
- log.info(tag, '✅ Queue is empty, no stale jobs to purge');
93
+ log.info(tag, '✅ Queue is empty, nothing to purge');
101
94
  return;
102
95
  }
103
96
 
104
- log.info(tag, `Found ${queueLength} jobs in queue, checking for stale jobs...`);
105
-
106
- // Scan up to 100 jobs to find stale ones
107
- const MAX_SCAN = Math.min(queueLength, 100);
108
- const tempJobs: RefreshJob[] = [];
109
-
110
- for (let i = 0; i < MAX_SCAN; i++) {
111
- const job = await this.redisQueue.getWork(this.config.queueName, 1);
112
-
113
- if (!job) break;
114
-
115
- scannedCount++;
116
- const jobTimestamp = (job as any).timestamp || 0;
117
- const jobAge = jobTimestamp > 0 ? now - jobTimestamp : 0;
118
-
119
- if (jobAge > MAX_JOB_AGE_MS) {
120
- purgedCount++;
121
- log.warn(tag, ` Purged stale job: ${job.type} (age: ${Math.round(jobAge / 1000)}s)`);
122
- } else {
123
- // Keep fresh jobs - we'll re-queue them
124
- tempJobs.push(job);
125
- }
126
- }
127
-
128
- // Re-queue fresh jobs
129
- for (const job of tempJobs) {
130
- await this.redisQueue.createWork(this.config.queueName, job);
131
- }
132
-
133
- if (purgedCount > 0) {
134
- log.info(tag, `✅ Purged ${purgedCount} stale jobs (scanned ${scannedCount})`);
135
- } else {
136
- log.info(tag, `✅ No stale jobs found (scanned ${scannedCount})`);
137
- }
97
+ // Nuclear purge delete the entire Redis list
98
+ await this.redisQueue.delete(this.config.queueName);
99
+ log.info(tag, `✅ Purged entire queue on startup: ${queueLength} stale jobs dropped from "${this.config.queueName}"`);
138
100
 
139
101
  } catch (error) {
140
102
  log.error(tag, '⚠️ Error during startup purge (non-fatal):', error);
141
- // Don't throw - startup purge failure shouldn't prevent worker from starting
142
103
  }
143
104
  }
144
105
 
@@ -241,9 +202,7 @@ export class RefreshWorker {
241
202
  if (jobTimestamp > 0) {
242
203
  const actualJobAge = Date.now() - jobTimestamp;
243
204
  if (actualJobAge > MAX_JOB_AGE_MS) {
244
- log.error(tag, `⚠️ DROPPING STALE JOB: ${type} (age: ${Math.round(actualJobAge / 1000)}s, max: ${MAX_JOB_AGE_MS / 1000}s)`);
245
- log.error(tag, ` Job key: ${key}`);
246
- log.error(tag, ` Job has been removed from queue and will not be retried`);
205
+ log.warn(tag, `Dropped stale ${type} job (age: ${Math.round(actualJobAge / 1000)}s): ${key}`);
247
206
  return;
248
207
  }
249
208
  }
@@ -254,13 +213,8 @@ export class RefreshWorker {
254
213
  // Get the appropriate cache instance
255
214
  const cache = this.cacheRegistry.get(cacheName);
256
215
 
257
- // FIX #2: Drop unsupported job types with clear error message
258
216
  if (!cache) {
259
- log.error(tag, `❌ DROPPING UNSUPPORTED JOB: ${type}`);
260
- log.error(tag, ` Cache type "${cacheName}" is not registered in this worker`);
261
- log.error(tag, ` Registered caches: ${Array.from(this.cacheRegistry.keys()).join(', ') || 'NONE'}`);
262
- log.error(tag, ` Job key: ${key}`);
263
- log.error(tag, ` Job has been removed from queue and will not be retried`);
217
+ log.warn(tag, `Dropped unsupported ${type} job (no "${cacheName}" cache registered): ${key}`);
264
218
  return;
265
219
  }
266
220
 
@@ -314,6 +268,19 @@ export class RefreshWorker {
314
268
  }
315
269
  }
316
270
 
271
+ /**
272
+ * Purge the entire queue — drop all pending jobs immediately
273
+ */
274
+ async purgeQueue(): Promise<number> {
275
+ const tag = TAG + 'purgeQueue | ';
276
+ const count = await this.redisQueue.count(this.config.queueName);
277
+ if (count > 0) {
278
+ await this.redisQueue.delete(this.config.queueName);
279
+ log.info(tag, `✅ Purged ${count} jobs from "${this.config.queueName}"`);
280
+ }
281
+ return count;
282
+ }
283
+
317
284
  /**
318
285
  * Get worker statistics
319
286
  */