























@@ -27,6 +27,7 @@ const prepareBoundaryArtifactsBin = resolve(
2727);
2828const extensionPackageBoundaryBaseConfig = "../tsconfig.package-boundary.base.json";
2929const FAILURE_OUTPUT_TAIL_LINES = 40;
30+const STEP_OUTPUT_MAX_CHARS = 256 * 1024;
3031const SLOW_COMPILE_SUMMARY_LIMIT = 10;
3132const COMPILE_INPUT_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".json"]);
3233const ROOTDIR_BOUNDARY_CANARY_IMPORT_PATH =
@@ -85,6 +86,26 @@ function formatFailureFooter(params = {}) {
8586return footerLines.join("\n");
8687}
878889+function createStepOutputCapture() {
90+return { text: "", truncatedChars: 0 };
91+}
92+93+export function appendBoundedStepOutput(buffer, chunk, maxChars = STEP_OUTPUT_MAX_CHARS) {
94+const nextText = buffer.text + String(chunk);
95+if (nextText.length <= maxChars) {
96+return { text: nextText, truncatedChars: buffer.truncatedChars };
97+}
98+const truncatedChars = buffer.truncatedChars + nextText.length - maxChars;
99+return { text: nextText.slice(-maxChars), truncatedChars };
100+}
101+102+function formatCapturedStepOutput(buffer) {
103+if (buffer.truncatedChars === 0) {
104+return buffer.text;
105+}
106+return `[output truncated ${buffer.truncatedChars} chars; showing tail]\n${buffer.text}`;
107+}
108+88109export function formatBoundaryCheckSuccessSummary(params = {}) {
89110const lines = ["extension package boundary check passed"];
90111if (params.mode) {
@@ -347,29 +368,31 @@ export function runNodeStepAsync(label, args, timeoutMs, params = {}) {
347368stdio: ["ignore", "pipe", "pipe"],
348369});
349370350-let stdout = "";
351-let stderr = "";
371+let stdout = createStepOutputCapture();
372+let stderr = createStepOutputCapture();
352373let settled = false;
353374const timer = setTimeout(() => {
354375if (settled) {
355376return;
356377}
357378settled = true;
358379child.kill("SIGKILL");
380+const stdoutText = formatCapturedStepOutput(stdout);
381+const stderrText = formatCapturedStepOutput(stderr);
359382const error = attachStepFailureMetadata(
360383new Error(
361384formatStepFailure(label, {
362- stdout,
363- stderr,
385+stdout: stdoutText,
386+stderr: stderrText,
364387kind: "timeout",
365388elapsedMs: Date.now() - startedAt,
366389note: `${label} timed out after ${timeoutMs}ms`,
367390}),
368391),
369392label,
370393{
371- stdout,
372- stderr,
394+stdout: stdoutText,
395+stderr: stderrText,
373396kind: "timeout",
374397elapsedMs: Date.now() - startedAt,
375398note: `${label} timed out after ${timeoutMs}ms`,
@@ -383,10 +406,10 @@ export function runNodeStepAsync(label, args, timeoutMs, params = {}) {
383406child.stdout.setEncoding("utf8");
384407child.stderr.setEncoding("utf8");
385408child.stdout.on("data", (chunk) => {
386-stdout += chunk;
409+stdout = appendBoundedStepOutput(stdout, chunk);
387410});
388411child.stderr.on("data", (chunk) => {
389-stderr += chunk;
412+stderr = appendBoundedStepOutput(stderr, chunk);
390413});
391414child.on("error", (error) => {
392415if (settled) {
@@ -404,20 +427,22 @@ export function runNodeStepAsync(label, args, timeoutMs, params = {}) {
404427);
405428return;
406429}
430+const stdoutText = formatCapturedStepOutput(stdout);
431+const stderrText = formatCapturedStepOutput(stderr);
407432const failure = attachStepFailureMetadata(
408433new Error(
409434formatStepFailure(label, {
410- stdout,
411- stderr,
435+stdout: stdoutText,
436+stderr: stderrText,
412437kind: "spawn-error",
413438elapsedMs: Date.now() - startedAt,
414439note: error.message,
415440}),
416441),
417442label,
418443{
419- stdout,
420- stderr,
444+stdout: stdoutText,
445+stderr: stderrText,
421446kind: "spawn-error",
422447elapsedMs: Date.now() - startedAt,
423448note: error.message,
@@ -434,22 +459,28 @@ export function runNodeStepAsync(label, args, timeoutMs, params = {}) {
434459clearTimeout(timer);
435460settled = true;
436461if (code === 0) {
437-resolvePromise({ stdout, stderr, elapsedMs: Date.now() - startedAt });
462+resolvePromise({
463+stdout: formatCapturedStepOutput(stdout),
464+stderr: formatCapturedStepOutput(stderr),
465+elapsedMs: Date.now() - startedAt,
466+});
438467return;
439468}
469+const stdoutText = formatCapturedStepOutput(stdout);
470+const stderrText = formatCapturedStepOutput(stderr);
440471const error = attachStepFailureMetadata(
441472new Error(
442473formatStepFailure(label, {
443- stdout,
444- stderr,
474+stdout: stdoutText,
475+stderr: stderrText,
445476kind: "nonzero-exit",
446477elapsedMs: Date.now() - startedAt,
447478}),
448479),
449480label,
450481{
451- stdout,
452- stderr,
482+stdout: stdoutText,
483+stderr: stderrText,
453484kind: "nonzero-exit",
454485elapsedMs: Date.now() - startedAt,
455486},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。