bulltrackers-module 1.0.668 → 1.0.669
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.
|
@@ -38,7 +38,18 @@ async function tryLoadFromGCS(config, dateString, snapshotName, logger) {
|
|
|
38
38
|
if (exists) {
|
|
39
39
|
logger.log('INFO', `[DataLoader] ⚡️ GCS HIT: ${snapshotName} for ${dateString}`);
|
|
40
40
|
const [content] = await file.download();
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
// FIX: GCS client auto-decompresses if Content-Encoding is gzip.
|
|
43
|
+
// We try gunzip first; if it fails with header check, it's likely already JSON.
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(zlib.gunzipSync(content).toString());
|
|
46
|
+
} catch (zipError) {
|
|
47
|
+
if (zipError.message && zipError.message.includes('incorrect header check')) {
|
|
48
|
+
// Content was already decompressed by the client
|
|
49
|
+
return JSON.parse(content.toString());
|
|
50
|
+
}
|
|
51
|
+
throw zipError;
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
} catch (e) {
|
|
44
55
|
logger.log('WARN', `[DataLoader] GCS Check Failed (${snapshotName}): ${e.message}`);
|
|
@@ -434,7 +445,19 @@ async function* streamPortfolioData(config, deps, dateString, providedRefs = nul
|
|
|
434
445
|
if (exists) {
|
|
435
446
|
logger.log('INFO', `[DataLoader] ⚡️ STREAMING: Hydrating Portfolios from GCS Snapshot`);
|
|
436
447
|
const [content] = await file.download();
|
|
437
|
-
|
|
448
|
+
|
|
449
|
+
// FIX: Handle Double Decompression
|
|
450
|
+
let fullData;
|
|
451
|
+
try {
|
|
452
|
+
fullData = JSON.parse(zlib.gunzipSync(content).toString());
|
|
453
|
+
} catch (zipError) {
|
|
454
|
+
if (zipError.message && zipError.message.includes('incorrect header check')) {
|
|
455
|
+
fullData = JSON.parse(content.toString());
|
|
456
|
+
} else {
|
|
457
|
+
throw zipError;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
438
461
|
yield fullData; // Yield all in one chunk as it fits in memory
|
|
439
462
|
return;
|
|
440
463
|
}
|
|
@@ -473,7 +496,7 @@ async function* streamHistoryData(config, deps, dateString, providedRefs = null,
|
|
|
473
496
|
if (exists) {
|
|
474
497
|
logger.log('INFO', `[DataLoader] ⚡️ STREAMING: Hydrating History from GCS (JSONL)`);
|
|
475
498
|
|
|
476
|
-
const fileStream = file.createReadStream()
|
|
499
|
+
const fileStream = file.createReadStream();
|
|
477
500
|
const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
|
478
501
|
|
|
479
502
|
let currentBatch = {};
|