next-leak 0.1.3 → 0.2.0

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/trend.d.ts CHANGED
@@ -16,9 +16,44 @@ export type TrendResult = {
16
16
  source?: "heap" | "external";
17
17
  };
18
18
  export type TrendOptions = {
19
- /** Minimum per-cycle growth (bytes) considered leak-like. Default: 256 KiB. */
19
+ /**
20
+ * Minimum per-cycle growth (bytes) considered leak-like. Defaults to the
21
+ * noise floor alone — callers that know how much traffic ran should pass
22
+ * `minGrowthFor(requestsPerCycle)` instead.
23
+ */
20
24
  minGrowthPerCycle?: number;
21
25
  };
26
+ /**
27
+ * Smallest per-cycle growth distinguishable from measurement noise.
28
+ *
29
+ * This is a property of the *instrument*, not of the leak: post-GC samples
30
+ * jitter by roughly this much regardless of how much traffic ran, so no amount
31
+ * of load makes growth below it meaningful.
32
+ */
33
+ export declare const MIN_GROWTH_NOISE_FLOOR: number;
34
+ /**
35
+ * Growth rate that counts as leak-like, per 1000 requests.
36
+ *
37
+ * This is a property of the *leak*: a route that retains memory per request
38
+ * grows in proportion to the traffic it served, so the gate has to scale with
39
+ * it. 51.2 KiB is the rate that leaves the default profile (5000 requests per
40
+ * cycle) on exactly the 256 KiB gate this tool was validated against.
41
+ */
42
+ export declare const MIN_GROWTH_PER_1000_REQUESTS: number;
43
+ /**
44
+ * The gate a per-cycle delta must clear to count as growth.
45
+ *
46
+ * `max` rather than a sum, because the two terms bound different things: the
47
+ * floor is what the instrument can resolve, the rate is what the leak should
48
+ * produce. Below ~5000 requests per cycle the floor dominates and the run is
49
+ * noise-limited — which is a real limit of measuring less traffic, not a
50
+ * threshold that can be lowered.
51
+ *
52
+ * Without this, the verdict silently depended on `--requests`: the same route
53
+ * leaking 100 KiB per 1000 requests printed the same headline in every mode
54
+ * but came out `stable` at 2000 requests per cycle and `leak` at 5000.
55
+ */
56
+ export declare function minGrowthFor(requestsPerCycle: number): number;
22
57
  /**
23
58
  * Classifies a series of post-GC retained-heap samples — baseline first, then
24
59
  * one sample per load cycle — as leaking or stable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-leak",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Find out whether your Next.js app actually leaks memory — how much, on which route, and whose fault it is.",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -27,14 +27,15 @@
27
27
  "main": "./dist/index.js",
28
28
  "types": "./dist/index.d.ts",
29
29
  "files": [
30
- "dist"
30
+ "dist",
31
+ "THIRD-PARTY-NOTICES.md"
31
32
  ],
32
33
  "engines": {
33
34
  "node": ">=22"
34
35
  },
35
36
  "packageManager": "pnpm@10.20.0",
36
37
  "scripts": {
37
- "build": "tsup && tsc -p tsconfig.build.json",
38
+ "build": "tsup && tsc -p tsconfig.build.json && node scripts/generate-notices.mjs && node scripts/check-bundle.mjs",
38
39
  "dev": "tsup --watch",
39
40
  "test": "vitest run",
40
41
  "test:watch": "vitest",