-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stdout gets truncated #242
Comments
Looks like trying to open await file. Make sure your shell supports heredoc. |
Oops.. messed up replicating the error. Clarified the issue. For what it is worth, the only workaround I could think of that works is: unimported_output=$(mktemp);
unimported > "$unimported_output";
ts-node --transpile-only bin/delete-unimported.ts < "$unimported_output" |
Can you create an example so I can debug the issue? For me zx captures everything okay. |
echo 'console.log(
`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non tellus ac eros mattis vehicula. Donec ac hendrerit urna. Suspendisse metus purus, venenatis ut consectetur eu, mattis id orci. Fusce vehicula mattis rutrum. Pellentesque et viverra risus. Donec id odio sit amet nibh maximus fringilla et in nulla. Nulla nec mi sit amet ex aliquet eleifend ac vel ligula. Aenean eleifend elementum turpis, et convallis odio hendrerit at. In quis eros eu tellus laoreet semper efficitur a neque. Pellentesque risus lectus, tempus nec arcu quis, sagittis suscipit turpis. Aliquam fringilla arcu ante. Aliquam varius odio ut nisl hendrerit mollis. Mauris a nisi ligula. Ut dapibus tristique finibus.
`.repeat(100)
);
console.log("end");
process.exit(1);
' > test.js
zx <<'EOF'
await $`node test.js`
EOF This replicates what's happening with unimported. I expect the last line of output to be In contrast, if you just execute |
I think I get it. Calling process.exit(1) will force exit it without waiting. process.exitCode = 1; |
That's all good, but I don't get to control how other programs are implemented. This issue just highlights that zx cannot capture the output of applications that exit this way, where as just running them in bash works. |
Looks like it's nodejs isses. See nodejs/node#6379 I was not able to find a solution from the client-side. As a mitigation: file a bug to affected projects. |
But yes, in bash it outputs full text. So maybe there is a workaround. But I don’t know how to do it. ¯\(ツ)/¯ |
Other languages also see only truncated output:
|
I cannot think of a nice workaround, but... you could make it work using the same workaround that I've shared earlier, i.e. const child = spawn("bash", ["-c", "node print.js > foo"], {
cwd: __dirname,
}); Where |
This is not really elegant solution =( |
What's the downside of this workaround? From user's perspective it gets the job done. |
How parallel executions will work? |
These two shouldn't be an issue using tmp files in memory.
Cannot think of a solution for this though. |
I've been digging through different ways to make this work and found this solution: const { spawn } = require("child_process");
const child = spawn("script", ["-q", "/dev/null", "node", "./print.js"], {
cwd: __dirname,
});
child.stdout.on("data", (data) => {
console.log(String(data));
}); It captures the entire output. |
I wrote a doc on how to deal with this issue: https://google.github.io/zx/known-issues#output-gets-truncated |
Expected Behavior
Capture the entire output of the program in the result.
Actual Behavior
Produces result, but cuts off half-way:
Expected behavior
Result of the program is captured in its entirety.
The actual output is a lot longer and ends with a summary:
Specifications
The text was updated successfully, but these errors were encountered: