Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Changes since the last non-beta release.
##### Fixed

- **Fix streaming SSR hangs and silent error absorption in RSC payload injection**: Fixed two related issues: (1) streaming SSR renders hanging forever when errors occur because Node.js `stream.pipe()` doesn't propagate errors or closure from source to destination, and (2) errors in the RSC payload injection pipeline being silently absorbed, preventing them from reaching error reporters like Sentry. Introduced a shared `safePipe` utility and used `'close'` events as reliable termination signals across the streaming pipeline (Node renderer, RSC payload injection, transform streams, and Ruby async task). Also added a Ruby safety net to prevent Rails request hangs when async rendering tasks raise before the first chunk. [PR 2407](https://github.com/shakacode/react_on_rails/pull/2407) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
- **Handle HTTPX error responses when fetching dev-server bundle/assets for upload**: During development startup races, `get_form_body_for_file` could receive `HTTPX::ErrorResponse` and still call `response.body`, causing an unexpected crash path. The request layer now raises `ReactOnRailsPro::Error` with HTTPX error details before body access and includes regression tests for local path, HTTP success, and HTTP error cases. [PR 2532](https://github.com/shakacode/react_on_rails/pull/2532) by [justin808](https://github.com/justin808).

### [16.4.0.rc.5] - 2026-02-26

Expand Down
3 changes: 3 additions & 0 deletions react_on_rails_pro/lib/react_on_rails_pro/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ def get_form_body_for_file(path)
end

response = HTTPX.get(path)
error = response.error if response.respond_to?(:error)
raise ReactOnRailsPro::Error, "Failed to fetch dev-server asset from #{path}: #{error}" if error
Comment thread
justin808 marked this conversation as resolved.
Outdated
Comment thread
justin808 marked this conversation as resolved.
Outdated
Comment thread
justin808 marked this conversation as resolved.
Outdated

response.body
else
Pathname.new(path)
Expand Down
30 changes: 30 additions & 0 deletions react_on_rails_pro/spec/react_on_rails_pro/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,36 @@
end
end

describe "get_form_body_for_file" do
let(:url_path) { "http://localhost:3035/webpack/development/server-bundle.js" }

it "returns a pathname for file paths" do
result = described_class.send(:get_form_body_for_file, server_bundle_path)
expect(result).to be_a(FakeFS::Pathname)
expect(result.to_s).to eq(server_bundle_path)
end

it "returns response body for HTTP urls in development mode" do
Comment thread
justin808 marked this conversation as resolved.
response = instance_double(HTTPX::Response, body: "mock bundle content", error: nil)
Comment thread
justin808 marked this conversation as resolved.
Outdated
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("development"))
allow(HTTPX).to receive(:get).with(url_path).and_return(response)

result = described_class.send(:get_form_body_for_file, url_path)
expect(result).to eq("mock bundle content")
end

it "raises ReactOnRailsPro::Error when HTTPX returns an error response" do
http_error = StandardError.new("connection refused")
error_response = instance_double(HTTPX::ErrorResponse, error: http_error)
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("development"))
allow(HTTPX).to receive(:get).with(url_path).and_return(error_response)

expect do
described_class.send(:get_form_body_for_file, url_path)
end.to raise_error(ReactOnRailsPro::Error, /connection refused/)
Comment thread
justin808 marked this conversation as resolved.
Outdated
end
end

describe "thread-safe connection management" do
let(:mock_connection) { instance_double(HTTPX::Session) }

Expand Down
Loading