Skip to content

Commit 075e91e

Browse files
Fix HTTPX stream_bidi plugin bug preventing connection cleanup
Add monkey-patch for missing inflight? method in HTTPX::Plugins::StreamBidi::Signal class. This fixes NoMethodError when closing persistent bidirectional streaming connections, which is required for incremental rendering feature. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 19f1ed2 commit 075e91e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

react_on_rails_pro/lib/react_on_rails_pro.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
require "rails"
44

5+
# Apply HTTPX bug fix for stream_bidi plugin
6+
require "react_on_rails_pro/httpx_stream_bidi_patch"
7+
58
require "react_on_rails_pro/request"
69
require "react_on_rails_pro/version"
710
require "react_on_rails_pro/constants"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
# Temporary monkey-patch for HTTPX bug with stream_bidi plugin + persistent connections
4+
#
5+
# Issue: When using HTTPX with both `persistent: true` and `.plugin(:stream_bidi)`,
6+
# calling `session.close` raises NoMethodError: undefined method `inflight?` for
7+
# an instance of HTTPX::Plugins::StreamBidi::Signal
8+
#
9+
# Root cause: The StreamBidi::Signal class is registered as a selectable in the
10+
# selector but doesn't implement the `inflight?` method required by Selector#terminate
11+
# (called during session close at lib/httpx/selector.rb:64)
12+
#
13+
# This patch adds the missing `inflight?` method to Signal. The method returns false
14+
# because Signal objects are just pipe-based notification mechanisms to wake up the
15+
# selector loop - they never have "inflight" HTTP requests or pending data buffers.
16+
#
17+
# The `unless method_defined?` guard ensures this patch won't override the method
18+
# when the official fix is released, making it safe to keep in the codebase.
19+
#
20+
# Can be removed once httpx releases an official fix.
21+
# Affected versions: httpx 1.5.1 (and possibly earlier)
22+
# See: https://github.com/HoneyryderChuck/httpx/issues/XXX
23+
24+
module HTTPX
25+
module Plugins
26+
module StreamBidi
27+
class Signal
28+
unless method_defined?(:inflight?)
29+
def inflight?
30+
false
31+
end
32+
end
33+
end
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)