Skip to content
Closed
Show file tree
Hide file tree
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
23 changes: 20 additions & 3 deletions react_on_rails_pro/lib/react_on_rails_pro/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def perform_request(path, **post_options) # rubocop:disable Metrics/AbcSize,Metr
"[ReactOnRailsPro] Timed out trying to make a request to the Node Renderer. " \
"Retrying #{available_retries} more times..."
end
Rails.logger.error("An error occured and react on rails retry is going to be made")
Rails.logger.error("Error: #{e}")
Rails.logger.error("Post Options: #{post_options}")
available_retries -= 1
next
rescue HTTPX::Error => e # Connection errors or other unexpected errors
Expand Down Expand Up @@ -227,7 +230,17 @@ def create_connection
# For persistent connections we want retries,
# so the requests don't just fail if the other side closes the connection
# https://honeyryderchuck.gitlab.io/httpx/wiki/Persistent
.plugin(:retries, max_retries: 1, retry_change_requests: true)
.plugin(
:retries,
max_retries: 1,
retry_change_requests: true,
retry_after: ->(req, res) do
Rails.logger.error("An error occured and retry is going to be made")
Rails.logger.error("Error: #{res.error}")
Rails.logger.error("Request Body: #{req.body&.to_s.first(1000)}")
nil
end,
)
.plugin(:stream)
# See https://www.rubydoc.info/gems/httpx/1.3.3/HTTPX%2FOptions:initialize for the available options
.with(
Expand All @@ -244,8 +257,12 @@ def create_connection
# :operation_timeout
# :keep_alive_timeout
timeout: {
connect_timeout: ReactOnRailsPro.configuration.renderer_http_pool_timeout,
read_timeout: ReactOnRailsPro.configuration.ssr_timeout
connect_timeout: 100,
read_timeout: 100,
write_timeout: 100,
request_timeout: 100,
operation_timeout: 100,
keep_alive_timeout: 100,
}
)
rescue StandardError => e
Expand Down
5 changes: 5 additions & 0 deletions react_on_rails_pro/packages/node-renderer/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export default function run(config: Partial<Config>) {
logger:
logHttpLevel !== 'silent' ? { name: 'RORP HTTP', level: logHttpLevel, ...sharedLoggerOptions } : false,
...fastifyServerOptions,
pluginTimeout: 1_000_1000,
requestTimeout: 1_000_1000,
keepAliveTimeout: 1_000_1000,
connectionTimeout: 1_000_1000,
http2SessionTimeout: 1_000_1000,
});

// We shouldn't have unhandled errors here, but just in case
Expand Down
Loading