Bug Description
In node/opendataloader-pdf/src/index.ts, when convert() is called from the CLI without the quiet flag, output is written to process.stdout twice.
Root Cause
executeJar() is called with streamOutput: !options.quiet. When streamOutput=true, every data chunk from the Java process is immediately written to process.stdout:
javaProcess.stdout.on('data', (data) => {
const chunk = data.toString();
if (streamOutput) {
process.stdout.write(chunk); // <-- writes to stdout in real-time
}
stdout += chunk; // <-- also accumulated
});
Then the resolved stdout string is returned back to cli.ts, which writes it again:
// cli.ts
const output = await convert(inputPaths, convertOptions);
if (output && !convertOptions.quiet) {
process.stdout.write(output); // <-- second write of the same content!
}
Fix
When streamOutput=true, the accumulated stdout variable should be returned as an empty string (since it was already written to `process.stdout' in real-time), preventing the CLI from double-printing.
javaProcess.on('close', (code) => {
if (code === 0) {
// If already streamed, return empty to avoid double-write by caller
resolve(streamOutput ? '' : stdout);
} else {
...
}
});
Impact
All CLI users who do not pass --quiet see every line of output duplicated. This is a significant UX regression.
Affected File
node/opendataloader-pdf/src/index.ts
Bug Description
In
node/opendataloader-pdf/src/index.ts, whenconvert()is called from the CLI without thequietflag, output is written toprocess.stdouttwice.Root Cause
executeJar()is called withstreamOutput: !options.quiet. WhenstreamOutput=true, every data chunk from the Java process is immediately written toprocess.stdout:Then the resolved
stdoutstring is returned back tocli.ts, which writes it again:Fix
When
streamOutput=true, the accumulatedstdoutvariable should be returned as an empty string (since it was already written to `process.stdout' in real-time), preventing the CLI from double-printing.Impact
All CLI users who do not pass
--quietsee every line of output duplicated. This is a significant UX regression.Affected File
node/opendataloader-pdf/src/index.ts