fix(sse): fix memory leaks in SSE stream cleanup and add memory telemetry#3378
fix(sse): fix memory leaks in SSE stream cleanup and add memory telemetry#3378waleedlatif1 merged 7 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
e7dec5f to
cf2a497
Compare
|
@cursor review |
|
@greptile |
Greptile SummaryThis PR systematically addresses SSE memory leaks and adds observability for tracking them. The changes add missing Key improvements:
Note on workflow execution behavior: Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SSE Stream Created] --> B[start called]
B --> C[incrementSSEConnections]
C --> D{Stream Active}
D -->|Client Disconnects| E[abort event fires]
D -->|Normal Flow| F[Stream Processing]
E --> G{once: true}
G --> H[cleanup called]
D -->|Stream Cancelled| I[cancel handler]
I --> H
F -->|Complete/Error| J[finally block]
J --> H
H --> K{Guard Flag Check}
K -->|Not Cleaned| L[Clear intervals/timeouts]
L --> M[Unsubscribe listeners]
M --> N[decrementSSEConnections]
N --> O[Set cleaned=true]
K -->|Already Cleaned| P[Skip - idempotent]
O --> Q[Stream Closed]
P --> Q
style H fill:#90EE90
style K fill:#FFE4B5
style N fill:#87CEEB
Last reviewed commit: a3a7e17 |
cf2a497 to
2b37d5b
Compare
2b37d5b to
979cae7
Compare
|
@cursor review |
|
@greptile |
…and a2a-message endpoints
Additional Comments (1)
Any events that Since One approach is to not call |
…ween start() and cancel()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
|
@cursor review |
|
@greptile |
Summary
cancel()handler — leaked intervals and pub/sub subscribers on disconnectcancel()not aborting execution — workflows continued running after client disconnect{ once: true }— listener closures held until GCType of Change
Testing
bunx tsc --noEmit)bunx vitest run)bun run lint)Checklist