Merged
Size
XS
Change Breakdown
Performance50%
Bug Fix40%
Security10%
#28246fix(API): Disable response compression on instance-ai SSE connections (no-changelog)

SSE compression memory leak patched

SSE connections no longer leak native memory through orphaned compression streams, cutting resource consumption by two-thirds under load.

Server-Sent Events endpoints were leaking native memory through compression streams. The global compression middleware was allocating a zlib compressor for each SSE connection, and these compressors persist until TCP timeout. Under load balancers, browsers reconnect frequently during network blips or tab backgrounding — leaving orphaned compressors accumulating in the background.

Two SSE endpoints in the instance-ai module now include no-transform in their Cache-Control headers, opting out of compression entirely. This prevents the compression middleware from allocating streams that would otherwise leak. Benchmarks show delegation overhead dropped from 3x to near baseline after this change.

In the CLI package, the file handles both the /events/:threadId and /gateway/events endpoints — both now carry the no-transform directive.

View Original GitHub Description

Summary

Adds no-transform to Cache-Control on both instance-ai SSE endpoints (/events/:threadId and /gateway/events). This prevents the global compression middleware from allocating a zlibcompressor stream per connection. Each compressor holds native memory for the lifetime of the SSE connection. Behind load balancers, orphaned connections accumulate when browsers reconnect after network blips or tab backgrounding, the old connection's compressor stays alive until TCP timeout.

Before (delegation benchmark scenario ran 3x): <img width="581" height="410" alt="CleanShot 2026-04-09 at 13 58 31" src="https://github.com/user-attachments/assets/d5e04a0e-d6d2-4c32-b962-e61698ff457b" />

After: <img width="922" height="454" alt="CleanShot 2026-04-09 at 13 58 00" src="https://github.com/user-attachments/assets/78874c5a-ab66-4cc9-9dbf-8813fa3bec37" />

Related Linear tickets, Github issues, and Community forum posts

<!-- Include links to **Linear ticket** or Github issue or Community forum post. Important in order to close *automatically* and provide context to reviewers. https://linear.app/n8n/issue/ --> <!-- Use "closes #<issue-number>", "fixes #<issue-number>", or "resolves #<issue-number>" to automatically close issues when the PR is merged. -->

Review / Merge checklist

  • PR title and summary are descriptive. (conventions) <!-- **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** -->
  • Docs updated or follow-up ticket created.
  • Tests included. <!-- A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. -->
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)
© 2026 · via Gitpulse