next-evolve 0.4.0 → 0.4.1
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/core/log.d.ts +6 -2
- package/dist/core/log.js +7 -3
- package/dist/store/memory.js +1 -1
- package/package.json +1 -1
package/dist/core/log.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Logs at most once per `intervalMs` per key (default 60 s), so a hot path can't flood logs.
|
|
3
|
+
* `level: "info"` is for normal states worth a line (stdout); hosts such as Vercel show
|
|
4
|
+
* stderr lines as errors.
|
|
5
|
+
*/
|
|
6
|
+
export declare function logRateLimited(key: string, message: string, err?: unknown, intervalMs?: number, level?: "error" | "info"): void;
|
package/dist/core/log.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// src/core/log.ts
|
|
2
2
|
const last = /* @__PURE__ */ new Map();
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Logs at most once per `intervalMs` per key (default 60 s), so a hot path can't flood logs.
|
|
5
|
+
* `level: "info"` is for normal states worth a line (stdout); hosts such as Vercel show
|
|
6
|
+
* stderr lines as errors.
|
|
7
|
+
*/
|
|
8
|
+
function logRateLimited(key, message, err, intervalMs = 6e4, level = "error") {
|
|
5
9
|
const now = Date.now();
|
|
6
10
|
if ((last.get(key) ?? 0) + intervalMs > now) return;
|
|
7
11
|
last.set(key, now);
|
|
8
|
-
console.error(`[evolve] ${message}`, ...err === void 0 ? [] : [err]);
|
|
12
|
+
(level === "info" ? console.info : console.error)(`[evolve] ${message}`, ...err === void 0 ? [] : [err]);
|
|
9
13
|
}
|
|
10
14
|
export { logRateLimited };
|
package/dist/store/memory.js
CHANGED
|
@@ -43,7 +43,7 @@ function createMemoryStore(opts) {
|
|
|
43
43
|
schedule();
|
|
44
44
|
inflight = opts.fetcher(etag).then((res) => {
|
|
45
45
|
if (res.status === "ok") load(res.token);
|
|
46
|
-
else if (res.status === "error" && res.code === 404 && res.message?.includes("no_bundle")) logRateLimited("fetch:no_bundle", "no bundle yet (no experiment has started): serving control", void 0, 36e5);
|
|
46
|
+
else if (res.status === "error" && res.code === 404 && res.message?.includes("no_bundle")) logRateLimited("fetch:no_bundle", "no bundle yet (no experiment has started): serving control", void 0, 36e5, "info");
|
|
47
47
|
else if (res.status === "error") logRateLimited(`fetch:${res.code}`, `bundle fetch failed (${res.code})`, res.message);
|
|
48
48
|
}).catch((e) => logRateLimited("fetch:throw", "bundle fetch failed", e)).finally(() => {
|
|
49
49
|
inflight = null;
|