Pebble32 commented on code in PR #77306:
URL: https://github.com/apache/airflow/pull/77306#discussion_r4695566949
##########
ts-sdk/src/cli/pack.ts:
##########
@@ -115,24 +129,42 @@ function readSdkVersion(): string {
}
function readBundleManifest(bundlePath: string): BundleManifest {
+ // On macOS Node writes a piped stderr asynchronously, so output past the 64
KiB pipe buffer is
+ // lost when the bundle exits, and Node prints the whole minified line
before the error.
+ // Writes to a file are synchronous.
+ const stderrDir = mkdtempSync(path.join(tmpdir(), "airflow-ts-pack-"));
+ const stderrPath = path.join(stderrDir, "stderr");
+ const stderrFd = openSync(stderrPath, "w");
let stdout: string;
try {
stdout = execFileSync(process.execPath, [bundlePath,
AIRFLOW_METADATA_FLAG], {
encoding: "utf-8",
+ stdio: ["pipe", "pipe", stderrFd],
timeout: MANIFEST_TIMEOUT_MS,
maxBuffer: MANIFEST_MAX_BUFFER_BYTES,
});
+ // Still pass on what a working bundle logs, such as warnings from user
code.
+ const { text, skippedBytes } = readEnd(stderrPath,
STDERR_READ_LIMIT_BYTES);
+ if (skippedBytes > 0) {
+ process.stderr.write(`[first ${skippedBytes} bytes of the bundle's
stderr omitted]\n`);
+ }
+ if (text) process.stderr.write(text);
} catch (error) {
- const stderr = (error as { stderr?: string }).stderr ?? "";
+ const stderr = readEnd(stderrPath, STDERR_READ_LIMIT_BYTES).text;
const reported = stderr
.split("\n")
.reverse()
.find((line) => /^\w*Error: /.test(line.trim()))
?.trim();
throw new Error(
- reported ?? `Running the bundle with ${AIRFLOW_METADATA_FLAG} failed:
${String(error)}`,
+ reported ??
+ `Running the bundle with ${AIRFLOW_METADATA_FLAG} failed:
${String(error)}\n` +
+ stderr.trimEnd().slice(-STDERR_TAIL_CHARS),
{ cause: error },
);
Review Comment:
I will take a look thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]