next-leak 0.4.1 → 0.4.2

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.
@@ -68,6 +68,7 @@ function classifyMemoryTrend(heapSamples, externalSamples, options = {}) {
68
68
  }
69
69
 
70
70
  // src/confidence.ts
71
+ var resolveCycles = (cycles) => Math.max(cycles * 2, 6);
71
72
  function effectiveVerdict(report) {
72
73
  return report.confidence.supersededVerdict ?? report.trend.verdict;
73
74
  }
@@ -235,6 +236,7 @@ export {
235
236
  minGrowthFor,
236
237
  classifyTrend,
237
238
  classifyMemoryTrend,
239
+ resolveCycles,
238
240
  effectiveVerdict,
239
241
  warrantsIssueDraft,
240
242
  assessConfidence
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __nextLeakCreateRequire } from 'node:module';import { fileURLToPath as __nextLeakFileURLToPath } from 'node:url';import { dirname as __nextLeakDirname } from 'node:path';const require = __nextLeakCreateRequire(import.meta.url);const __filename = __nextLeakFileURLToPath(import.meta.url);const __dirname = __nextLeakDirname(__filename);
2
2
  import {
3
3
  effectiveVerdict
4
- } from "./chunk-FFCY6POI.js";
4
+ } from "./chunk-2FZXZLZW.js";
5
5
  import {
6
6
  assessPeakPressure,
7
7
  describePeakPressure
@@ -5,8 +5,9 @@ import {
5
5
  classifyTrend,
6
6
  effectiveVerdict,
7
7
  minGrowthFor,
8
+ resolveCycles,
8
9
  warrantsIssueDraft
9
- } from "./chunk-FFCY6POI.js";
10
+ } from "./chunk-2FZXZLZW.js";
10
11
  import {
11
12
  assessPeakPressure,
12
13
  describePeakPressure
@@ -92487,7 +92488,7 @@ function formatReport(report) {
92487
92488
  );
92488
92489
  if (inconclusive.length > 0) {
92489
92490
  const routeList = inconclusive.map((route) => route.route).join(",");
92490
- const moreCycles = Math.max(report.parameters.cycles * 2, 6);
92491
+ const moreCycles = resolveCycles(report.parameters.cycles);
92491
92492
  lines.push(
92492
92493
  "",
92493
92494
  "hint: inconclusive means sustained sub-threshold growth \u2014 measure longer to resolve it:",
@@ -93254,7 +93255,14 @@ var ControlError = class extends Error {
93254
93255
  }
93255
93256
  };
93256
93257
  async function request(port, pathname) {
93257
- const response = await fetch(`http://127.0.0.1:${port}${pathname}`);
93258
+ let response;
93259
+ try {
93260
+ response = await fetch(`http://127.0.0.1:${port}${pathname}`);
93261
+ } catch (cause) {
93262
+ throw new ControlError(
93263
+ `control channel ${pathname} on port ${port} did not answer (${cause instanceof Error ? cause.message : String(cause)}) \u2014 the measured process is gone or its event loop is blocked`
93264
+ );
93265
+ }
93258
93266
  if (!response.ok) {
93259
93267
  throw new ControlError(`control channel ${pathname} responded ${response.status}`);
93260
93268
  }
@@ -93936,7 +93944,7 @@ async function measureRoute(context, route, requestPath, index, pass = void 0) {
93936
93944
  };
93937
93945
  }
93938
93946
  async function writeEvidenceBundle(report, workDir) {
93939
- const { renderHtmlReport } = await import("./html-report-76DP5ADD.js");
93947
+ const { renderHtmlReport } = await import("./html-report-X2LUOZRH.js");
93940
93948
  const { renderIssueMarkdown } = await import("./issue-report-HKA26WNV.js");
93941
93949
  for (const route of report.routes) {
93942
93950
  if (route.status === "measured" && warrantsIssueDraft(route)) {
@@ -93947,7 +93955,6 @@ async function writeEvidenceBundle(report, workDir) {
93947
93955
  }
93948
93956
  await writeFile(report.bundle.htmlReport, renderHtmlReport(report));
93949
93957
  }
93950
- var resolveCycles = (cycles) => Math.max(cycles * 2, 6);
93951
93958
  async function routeReportFor(context, route, index, total) {
93952
93959
  const { routeConfig, progress } = context;
93953
93960
  const label = `${route.path} (${index + 1}/${total})`;
@@ -93964,12 +93971,22 @@ async function routeReportFor(context, route, index, total) {
93964
93971
  if (first.status !== "measured" || context.options.resolveInconclusive === false || effectiveVerdict(first) !== "inconclusive") {
93965
93972
  return first;
93966
93973
  }
93974
+ if (context.options.signal?.aborted === true) {
93975
+ return first;
93976
+ }
93967
93977
  const cycles = resolveCycles(context.options.cycles ?? RITUAL_DEFAULTS.cycles);
93968
93978
  progress(`re-measuring ${route.path} with ${cycles} cycles: the first pass could not call it`);
93969
- return await measureRoute(context, route, requestPath, index, {
93970
- cycles,
93971
- dirSuffix: "-resolve"
93972
- });
93979
+ try {
93980
+ return await measureRoute(context, route, requestPath, index, {
93981
+ cycles,
93982
+ dirSuffix: "-resolve"
93983
+ });
93984
+ } catch (cause) {
93985
+ progress(
93986
+ `re-measurement of ${route.path} failed (${cause instanceof Error ? cause.message : String(cause)}) \u2014 keeping the first pass`
93987
+ );
93988
+ return first;
93989
+ }
93973
93990
  } catch (cause) {
93974
93991
  const failure = cause instanceof Error ? cause.message : String(cause);
93975
93992
  progress(`failed ${label}: ${failure}`);
package/dist/cli.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  killActiveChildren,
10
10
  parseCliArgs,
11
11
  runMeasurement
12
- } from "./chunk-OJIXF7RP.js";
13
- import "./chunk-FFCY6POI.js";
12
+ } from "./chunk-YDMJVVWG.js";
13
+ import "./chunk-2FZXZLZW.js";
14
14
  import "./chunk-XHPUAMJG.js";
15
15
  import "./chunk-6XYFBOL2.js";
16
16
 
@@ -45,6 +45,12 @@ export type ConfidenceInput = {
45
45
  /** Old-space cap the measured process ran under (MB). */
46
46
  maxOldSpaceMb?: number;
47
47
  };
48
+ /**
49
+ * Cycles a re-measurement uses when a verdict came back `inconclusive` — the
50
+ * same figure the report's manual re-run hint prints. One definition, imported
51
+ * by both, so the tool can never recommend one number and use another.
52
+ */
53
+ export declare const resolveCycles: (cycles: number) => number;
48
54
  /**
49
55
  * The verdict a route's evidence actually supports.
50
56
  *
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __nextLeakCreateRequire } from 'node:module';import { fileURLToPath as __nextLeakFileURLToPath } from 'node:url';import { dirname as __nextLeakDirname } from 'node:path';const require = __nextLeakCreateRequire(import.meta.url);const __filename = __nextLeakFileURLToPath(import.meta.url);const __dirname = __nextLeakDirname(__filename);
2
2
  import {
3
3
  renderHtmlReport
4
- } from "./chunk-BTWQYJOW.js";
5
- import "./chunk-FFCY6POI.js";
4
+ } from "./chunk-NNDGXIGQ.js";
5
+ import "./chunk-2FZXZLZW.js";
6
6
  import "./chunk-XHPUAMJG.js";
7
7
  import "./chunk-6XYFBOL2.js";
8
8
  export {
package/dist/index.js CHANGED
@@ -39,13 +39,13 @@ import {
39
39
  sourceIndexAt,
40
40
  summarizeBaseline,
41
41
  validateTarget
42
- } from "./chunk-OJIXF7RP.js";
42
+ } from "./chunk-YDMJVVWG.js";
43
43
  import {
44
44
  renderHtmlReport
45
- } from "./chunk-BTWQYJOW.js";
45
+ } from "./chunk-NNDGXIGQ.js";
46
46
  import {
47
47
  classifyTrend
48
- } from "./chunk-FFCY6POI.js";
48
+ } from "./chunk-2FZXZLZW.js";
49
49
  import {
50
50
  renderIssueMarkdown
51
51
  } from "./chunk-WXAFXVWS.js";
package/dist/runner.d.ts CHANGED
@@ -153,11 +153,6 @@ export type RunnerDeps = {
153
153
  };
154
154
  export declare function freePort(): Promise<number>;
155
155
  export declare function routeSlug(route: string): string;
156
- /**
157
- * Cycles a second pass uses — the same figure the report recommends for a
158
- * manual re-run, so the tool follows its own advice.
159
- */
160
- export declare const resolveCycles: (cycles: number) => number;
161
156
  /**
162
157
  * Full measurement run: validate the target, discover routes, run the ritual
163
158
  * per route in a fresh process, diff snapshots for non-stable verdicts, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-leak",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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",