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