removing fiber reference when emitting request completion event

This commit is contained in:
HoneyryderChuck 2025-08-07 22:42:14 +01:00
parent 8970767954
commit 09342187f5
3 changed files with 9 additions and 2 deletions

View File

@ -122,6 +122,11 @@ module HTTPX
@context == Fiber.current
end
def complete!(response = @response)
@context = nil
emit(:complete, response)
end
# whether request has been buffered with a ping
def ping?
@ping

View File

@ -326,7 +326,7 @@ module HTTPX
return responses unless request
catch(:coalesced) { selector.next_tick } until (response = fetch_response(request, selector, request.options))
request.emit(:complete, response)
request.complete!(response)
responses << response
requests.shift
@ -347,7 +347,7 @@ module HTTPX
response = fetch_response(req, selector, request.options)
if exit_from_loop && response
req.emit(:complete, response)
req.complete!(response)
responses << response
requests_to_remove << req
else

View File

@ -36,6 +36,8 @@ module HTTPX
def current_context?: () -> bool
def complete!: (?response response) -> void
def ping?: () -> bool
def ping!: () -> void