Copilot commented on code in PR #2005:
URL: https://github.com/apache/apisix-website/pull/2005#discussion_r2929255204


##########
scripts/generate-website.js:
##########
@@ -3,8 +3,33 @@ const util = require('util');
 const fs = require('fs');
 const path = require('path');
 const { chdir } = require('node:process');
+const { spawn } = require('node:child_process');
 const exec = util.promisify(require('node:child_process').exec);
 
+// Streams stdout/stderr to a log file via spawn (no maxBuffer limit).
+function runBuild(cmd, logFilePath) {
+  return new Promise((resolve) => {
+    const logStream = fs.createWriteStream(logFilePath);
+    const child = spawn(cmd, { shell: true, stdio: ['ignore', 'pipe', 'pipe'] 
});
+
+    child.stdout.pipe(logStream, { end: false });
+    child.stderr.pipe(logStream, { end: false });
+
+    child.on('close', (code) => {
+      logStream.end(() => {
+        resolve({ failed: code !== 0 });
+      });
+    });
+
+    child.on('error', (err) => {
+      logStream.write(`\nError: ${err.message}\n`);
+      logStream.end(() => {
+        resolve({ failed: true });

Review Comment:
   `runBuild()` doesn't handle `logStream` errors (e.g., permissions, ENOSPC). 
An `error` event on the WriteStream will be unhandled and can crash the Node 
process, potentially failing CI without a clear message. Add a 
`logStream.on('error', ...)` handler (and consider stopping the child process) 
and ensure the promise resolves/flags failure when the log file can't be 
written.
   



-- 
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]

Reply via email to