Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/core/agent/AntigravityProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ export class AntigravityProvider implements AgentProvider {
child.kill();
}, 5 * 60 * 1000);

const stdoutDecoder = new TextDecoder('utf-8');
const stderrDecoder = new TextDecoder('utf-8');
Comment thread
coderabbitai[bot] marked this conversation as resolved.

child.stdout!.on('data', (chunk: Buffer) => {
const text = chunk.toString();
const text = stdoutDecoder.decode(chunk, { stream: true });
stdoutFull += text;
stdoutBuffer += text;
const lines = stdoutBuffer.split(/\r?\n/);
Expand All @@ -129,7 +132,7 @@ export class AntigravityProvider implements AgentProvider {
}
});
child.stderr!.on('data', (chunk: Buffer) => {
const text = chunk.toString();
const text = stderrDecoder.decode(chunk, { stream: true });
stderrFull += text;
stderrBuffer += text;
});
Expand All @@ -138,6 +141,8 @@ export class AntigravityProvider implements AgentProvider {
done = true;
});
child.on('close', (code) => {
stdoutFull += stdoutDecoder.decode();
stderrFull += stderrDecoder.decode();
exitCode = code;
window.clearTimeout(timeout);
if (code && code !== 0) {
Expand Down
9 changes: 7 additions & 2 deletions src/core/cli/ExternalCliRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,27 @@ function runProcess(command: string, args: string[], env: NodeJS.ProcessEnv, cwd
windowsHide: false,
});

const stdoutDecoder = new TextDecoder('utf-8');
const stderrDecoder = new TextDecoder('utf-8');

const timeout = globalThis.setTimeout(() => {
child.kill('SIGTERM');
reject(new Error(`${path.basename(command)} timed out after ${Math.round(timeoutMs / 1000)} seconds`));
}, timeoutMs);

child.stdout?.on('data', (chunk: Buffer) => {
stdout += chunk.toString();
stdout += stdoutDecoder.decode(chunk, { stream: true });
});
child.stderr?.on('data', (chunk: Buffer) => {
stderr += chunk.toString();
stderr += stderrDecoder.decode(chunk, { stream: true });
});
child.on('error', (error) => {
globalThis.clearTimeout(timeout);
reject(error);
});
child.on('close', (code) => {
stdout += stdoutDecoder.decode();
stderr += stderrDecoder.decode();
globalThis.clearTimeout(timeout);
if (code && code !== 0) {
reject(new Error(`${path.basename(command)} exited with code ${code}\n${stderr || stdout}`.trim()));
Expand Down