fix: Minor streaming fixes (no-changelog) (#17683)

This commit is contained in:
oleg
2025-07-28 10:18:00 +02:00
committed by GitHub
parent e0ffadef34
commit e1aa60ce6f
11 changed files with 662 additions and 86 deletions

View File

@@ -513,7 +513,7 @@ describe('streaming functionality', () => {
expect(mockHooks.addHandler).toHaveBeenCalledWith('sendChunk', expect.any(Function));
});
it('should not setup sendChunk handler when streaming is enabled but execution mode is manual', async () => {
it('should setup sendChunk handler when streaming is enabled and execution mode is manual', async () => {
// ARRANGE
const activeExecutions = Container.get(ActiveExecutions);
jest.spyOn(activeExecutions, 'add').mockResolvedValue('1');
@@ -550,6 +550,6 @@ describe('streaming functionality', () => {
await runner.run(data);
// ASSERT
expect(mockHooks.addHandler).not.toHaveBeenCalledWith('sendChunk', expect.any(Function));
expect(mockHooks.addHandler).toHaveBeenCalledWith('sendChunk', expect.any(Function));
});
});

View File

@@ -268,12 +268,10 @@ export class WorkflowRunner {
});
if (data.streamingEnabled) {
if (data.executionMode !== 'manual') {
lifecycleHooks.addHandler('sendChunk', (chunk) => {
data.httpResponse?.write(JSON.stringify(chunk) + '\n');
data.httpResponse?.flush?.();
});
}
lifecycleHooks.addHandler('sendChunk', (chunk) => {
data.httpResponse?.write(JSON.stringify(chunk) + '\n');
data.httpResponse?.flush?.();
});
}
additionalData.setExecutionStatus = WorkflowExecuteAdditionalData.setExecutionStatus.bind({