mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
fix(core): prevent ModelInfo event emission on aborted signal (#16752)
This commit is contained in:
@@ -679,6 +679,34 @@ describe('Gemini Client (client.ts)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not emit ModelInfo event if signal is aborted', async () => {
|
||||
// Arrange
|
||||
mockTurnRunFn.mockReturnValue(
|
||||
(async function* () {
|
||||
yield { type: 'content', value: 'Hello' };
|
||||
})(),
|
||||
);
|
||||
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
|
||||
// Act
|
||||
const stream = client.sendMessageStream(
|
||||
[{ text: 'Hi' }],
|
||||
controller.signal,
|
||||
'prompt-id-1',
|
||||
);
|
||||
|
||||
const events = await fromAsync(stream);
|
||||
|
||||
// Assert
|
||||
expect(events).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: GeminiEventType.ModelInfo,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
compressionStatus:
|
||||
|
||||
@@ -627,8 +627,9 @@ export class GeminiClient {
|
||||
modelToUse = finalModel;
|
||||
|
||||
this.currentSequenceModel = modelToUse;
|
||||
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
||||
|
||||
if (!signal.aborted) {
|
||||
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
||||
}
|
||||
const resultStream = turn.run(modelConfigKey, request, linkedSignal);
|
||||
let isError = false;
|
||||
let isInvalidStream = false;
|
||||
|
||||
Reference in New Issue
Block a user