-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Long streaming model responses cause event loop starvation #89392
Copy link
Copy link
Closed as not planned
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.ClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.Decent issue quality, but reproduction details are still incomplete.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.ClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.Decent issue quality, but reproduction details are still incomplete.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Summary
When a model provider with large max output (e.g., DeepSeek v4 Pro, 384K tokens) returns very long streaming responses, the single-threaded Node.js event loop in the gateway gets starved. Stream chunk processing occupies the event loop without yielding, causing cascading delays across all gateway operations.
Diagnostic Evidence
From a session using deepseek-v4-pro on openclaw v2026.5.28 / Windows 10:
Event loop starvation
Normal delay < 50ms; here reached 6.5s at 98.7% utilization.
Fetch timeout delayed by stream processing
The 120s fetch timeout only fired after 207s — an 87-second delay because the timer callback was stuck behind stream chunk processing.
WebSocket response blocked
Returning chat history took 215 seconds.
Sidecar operations stalled
Impact
During these episodes the gateway is effectively unresponsive: timers misfire, WebSocket messages queue up, heartbeat/diagnostic events stall, and chat history responses are delayed by minutes.
Suggested Fix
Offload stream chunk processing to a worker thread, or insert periodic
setImmediate/process.nextTickyields during long streaming responses to give the event loop breathing room.