Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Flush responses for ai streaming endpoints #10633

Merged
merged 4 commits into from
Sep 2, 2024

Conversation

netroy
Copy link
Member

@netroy netroy commented Sep 2, 2024

Summary

When an endpoint in our current setup wants to stream responses, it needs to call res.flush() after every chunk is written.

In the long run we should probably move this check into ControllerRegistry, and check that if a controller method returns a ReadableStream, then we automatically setup streaming. But that requires a bit more refactor that is beyond the scope of this PR.

Review / Merge checklist

  • PR title and summary are descriptive

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Sep 2, 2024
@netroy netroy force-pushed the flush-streaming-ai-responses branch 2 times, most recently from c6cd76f to b1b27c7 Compare September 2, 2024 13:38
@MiloradFilipovic MiloradFilipovic self-requested a review September 2, 2024 13:43
Copy link
Contributor

@MiloradFilipovic MiloradFilipovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this works as expected but would like for somebody in the back-end team to take a look also.
A bit more context: This is a fix that enables AI Assistant intermediate steps streaming in Firefox (was working in Chrome without this).
You should be seeing something like this:
https://github.com/user-attachments/assets/324cbfa7-aa14-45bb-aedc-3a700fa1d5fd

In order to test in UI:

Copy link

cypress bot commented Sep 2, 2024

n8n    Run #6708

Run Properties:  status check passed Passed #6708  •  git commit 61a2980967: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 netroy 🗃️ e2e/*
Project n8n
Branch Review flush-streaming-ai-responses
Run status status check passed Passed #6708
Run duration 04m 44s
Commit git commit 61a2980967: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 netroy 🗃️ e2e/*
Committer कारतोफ्फेलस्क्रिप्ट™
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 422
View all changes introduced in this branch ↗︎

Copy link
Contributor

github-actions bot commented Sep 2, 2024

✅ All Cypress E2E specs passed

@netroy netroy force-pushed the flush-streaming-ai-responses branch from b1b27c7 to 61a2980 Compare September 2, 2024 14:04
@netroy netroy marked this pull request as ready for review September 2, 2024 14:10
Copy link
Contributor

@tomi tomi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Contributor

github-actions bot commented Sep 2, 2024

✅ All Cypress E2E specs passed

@netroy netroy merged commit 6bb6a5c into master Sep 2, 2024
34 checks passed
@netroy netroy deleted the flush-streaming-ai-responses branch September 2, 2024 14:47
MiloradFilipovic added a commit that referenced this pull request Sep 2, 2024
* master:
  fix(core): Flush responses for ai streaming endpoints (#10633)
  fix: Re-enable infra provisioning and teardown (no-changelog) (#10636)
  feat(core): Execution curation (#10342)
  fix(Webhook Node): Add tests for utils (no-changelog) (#10613)
  fix: Fixes to cloud benchmarks (no-changelog) (#10634)
  test: Add JS CodeNode benchmark scenario (#10632)
  refactor(editor): Migrate `MainSidebar.vue` to composition API (no-changelog) (#10538)
  build: Fix `cli` nodemon config (#10628)
  docs: Add 'benchmark' scope to PR Title Conventions documentation (#10624)
  ci: Fixes to benchmarks in cloud (#10626)
  test(editor): Increase test coverage for users settings page and modal (#10623)
  fix(Wait Node): Append n8n attribution option (#10585)
  refactor(editor): Migrate `NodeSettings.vue` to composition API (#10545)
  fix(editor): Add pinned data only to manual executions in execution view (#10605)
  ci: Omit benchmark scope commits from changelog (no-changelog) (#10618)
  fix: Disable errors obfuscation (no-changelog) (#10617)
  ci: Fix script name in gh workflow (#10619)
  ci: Fix nightly image not being pushed to ghcr (#10620)
@github-actions github-actions bot mentioned this pull request Sep 5, 2024
@janober
Copy link
Member

janober commented Sep 5, 2024

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants