Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apisix/plugins/ai-providers/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ function _M.parse_streaming_response(self, ctx, res, target_proto, converter)
else
plugin.lua_response_filter(ctx, res.headers, chunk)
end

-- WORKAROUND, not a real fix: yield to the nginx scheduler so other
-- coroutines on this worker (health checks, concurrent requests) can
-- run. body_reader() and ngx.flush() do not yield when the upstream
-- socket already has data buffered or the downstream client drains
-- immediately, so under bursty SSE upstreams this loop can monopolize
-- the worker CPU. ngx.sleep(0) only prevents a single request from
-- monopolizing the worker; it does not bound per-stream CPU time, add
-- backpressure, or time out stalled streams. See #13256 for a proper
-- solution.
ngx.sleep(0)
end
end

Expand Down
Loading