-
Notifications
You must be signed in to change notification settings - Fork 6
Description
I am running the action on our enterprise against our private repo. The result in github actions window is a long json follows by a Unexpected end of JSON input message.
Run avt/thirdparty.rustfmt-check@0.9.0
with:
token: ***
mode: review
commit-message: Format Rust code using rustfmt
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
/home/runner/.cargo/bin/cargo +nightly fmt -- --emit json
[{"name":"/_work/avt-runner-..............);\n"}]}]
Error: Unexpected end of JSON input
I have confirmed mulitple times that the string [{"name":"/_work/avt-runner-..............);\n"}]}] is a valid JSON. The JSON has 18938 bytes.
Looking at the source code, I see the following https://github.com/mbrobbel/rustfmt-check/blob/master/src/check.ts#L42 . Most probably 19000 bytes is more than output buffering, so I suspect what actually happens, is that only part of the JSON, most probably 16384 bytes, goes into add function. Because it is not a full message, add is not able to parse the full JSON.
Could this be changed into buffering, like https://github.com/mbrobbel/rustfmt-check/blob/master/src/rustfmt.ts#L18? Does fixing it to the following would work?
const buffer = "";
await exec.exec(
"cargo",
["+nightly", "fmt"]
.concat(stringArgv(args))
.concat(["--", "--emit", "json"]),
{
listeners: {
stdout: (data: buffer) => { buffer += data.toString(); },
},
},
);
const result: Result[] = [];
JSON.parse(buffer.trim()).forEach((output: Output) => {
output.mismatches.forEach((mismatch) => {
result.push({ path: output.name, mismatch });
});
});
return result;
Thanks