Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerna list output is truncated at 8192 bytes when execed #3970

Closed
jonscheiding opened this issue Mar 9, 2024 · 2 comments · Fixed by #3971
Closed

lerna list output is truncated at 8192 bytes when execed #3970

jonscheiding opened this issue Mar 9, 2024 · 2 comments · Fixed by #3971

Comments

@jonscheiding
Copy link

jonscheiding commented Mar 9, 2024

Current Behavior

When executing lerna list from within a Node process via exec or spawn, the stdout is truncated at 8192 bytes.

Expected Behavior

All stdout output should be captured.

This appears to have been introduced with bafe090, because the process.exit terminates the process handle before the output buffers are finished flushing.

Reference: https://stackoverflow.com/a/59322701/27578

Steps to Reproduce

Run this code in a monorepo which has a large enough number of packages to push the output of list past 8192 bytes.

const { exec } = require("child_process");

exec("npx lerna@8.1.2 list --all --json", (error, stdout, stderr) => {
  console.log(`stdout: ${stdout}`);
});

Other variantions tried:

const { exec } = require("child_process");

const process = exec("npx lerna@8.1.2 list --all --json");

let stdout = "";
process.stdout.on("data", (chunk) => (stdout += chunk));

process.on("close", () => {
  console.log(stdout);
});
const { spawn } = require("child_process");

const process = spawn("npx", ["lerna@8.1.2", "list", "--all", "--json"]);

let stdout = "";
process.stdout.on("data", (chunk) => (stdout += chunk));

process.on("close", () => {
  console.log(stdout);
});

These snippets work as expected with lerna@8.1.0.

@smerrill
Copy link
Contributor

smerrill commented Mar 9, 2024

image
Here is a simple reproduction and fix using our actual lerna list --all --json output. Without the process.stdout.end() callback, test2.js would only receive 8k and not our full 20k of output.

@RoXuS
Copy link

RoXuS commented Mar 13, 2024

+1 same issue during our release, hard to debug, all works as expected on 8.1.0.

This commit seems to be the culprit: bafe090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants