@adaptic/utils 0.0.917 → 0.0.918
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/dist/index.cjs +12 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +12 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/massive.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7523,6 +7523,12 @@ const rateLimiters = {
|
|
|
7523
7523
|
* "OK" = real-time data, "DELAYED" = delayed data (still valid, e.g. free-tier plans).
|
|
7524
7524
|
*/
|
|
7525
7525
|
const MASSIVE_VALID_STATUSES = new Set(["OK", "DELAYED"]);
|
|
7526
|
+
/**
|
|
7527
|
+
* Throttle map for DELAYED data warnings — logs once per ticker per 15 minutes
|
|
7528
|
+
* to avoid flooding logs when the entire feed is delayed (e.g. free-tier plans).
|
|
7529
|
+
*/
|
|
7530
|
+
const DELAYED_WARN_COOLDOWN_MS = 15 * 60 * 1000;
|
|
7531
|
+
const delayedWarnTimestamps = new Map();
|
|
7526
7532
|
// Constants from environment variables
|
|
7527
7533
|
const MASSIVE_API_KEY = process.env.MASSIVE_API_KEY;
|
|
7528
7534
|
// Define concurrency limits per API
|
|
@@ -7796,7 +7802,12 @@ const fetchPrices = async (params, options) => {
|
|
|
7796
7802
|
throw new Error(`Massive.com API responded with status: ${data.status}`);
|
|
7797
7803
|
}
|
|
7798
7804
|
if (data.status === "DELAYED") {
|
|
7799
|
-
|
|
7805
|
+
const now = Date.now();
|
|
7806
|
+
const lastWarn = delayedWarnTimestamps.get(params.ticker) ?? 0;
|
|
7807
|
+
if (now - lastWarn > DELAYED_WARN_COOLDOWN_MS) {
|
|
7808
|
+
delayedWarnTimestamps.set(params.ticker, now);
|
|
7809
|
+
getLogger().warn(`Massive.com returned DELAYED data for ${params.ticker} — using delayed results`, { ticker: params.ticker, source: "MassiveAPI.fetchPrices" });
|
|
7810
|
+
}
|
|
7800
7811
|
}
|
|
7801
7812
|
if (data.results) {
|
|
7802
7813
|
allResults = [...allResults, ...data.results];
|