mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix(cli): gemini command stuck in git bash (#6397)
Co-authored-by: Arya Gummadi <aryagummadi@google.com>
This commit is contained in:
@@ -67,4 +67,31 @@ describe('stdin context', () => {
|
||||
'Expected the model to identify the secret word from stdin',
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should exit quickly if stdin stream does not end', async () => {
|
||||
/*
|
||||
This simulates scenario where gemini gets stuck waiting for stdin.
|
||||
This happens in situations where process.stdin.isTTY is false
|
||||
even though gemini is intended to run interactively.
|
||||
*/
|
||||
|
||||
const rig = new TestRig();
|
||||
await rig.setup('should exit quickly if stdin stream does not end');
|
||||
|
||||
try {
|
||||
await rig.run({ stdinDoesNotEnd: true });
|
||||
throw new Error('Expected rig.run to throw an error');
|
||||
} catch (error: unknown) {
|
||||
expect(error).toBeInstanceOf(Error);
|
||||
const err = error as Error;
|
||||
|
||||
expect(err.message).toContain('Process exited with code 1');
|
||||
expect(err.message).toContain('No input provided via stdin.');
|
||||
console.log('Error message:', err.message);
|
||||
}
|
||||
const lastRequest = rig.readLastApiRequest();
|
||||
expect(lastRequest).toBeNull();
|
||||
|
||||
// If this test times out, runs indefinitely, it's a regression.
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
@@ -177,7 +177,9 @@ export class TestRig {
|
||||
}
|
||||
|
||||
run(
|
||||
promptOrOptions: string | { prompt?: string; stdin?: string },
|
||||
promptOrOptions:
|
||||
| string
|
||||
| { prompt?: string; stdin?: string; stdinDoesNotEnd?: boolean },
|
||||
...args: string[]
|
||||
): Promise<string> {
|
||||
let command = `node ${this.bundlePath} --yolo`;
|
||||
@@ -221,7 +223,13 @@ export class TestRig {
|
||||
if (execOptions.input) {
|
||||
child.stdin!.write(execOptions.input);
|
||||
}
|
||||
child.stdin!.end();
|
||||
|
||||
if (
|
||||
typeof promptOrOptions === 'object' &&
|
||||
!promptOrOptions.stdinDoesNotEnd
|
||||
) {
|
||||
child.stdin!.end();
|
||||
}
|
||||
|
||||
child.stdout!.on('data', (data: Buffer) => {
|
||||
stdout += data;
|
||||
|
||||
Reference in New Issue
Block a user