diff --git a/react_on_rails_pro/lib/react_on_rails_pro/request.rb b/react_on_rails_pro/lib/react_on_rails_pro/request.rb index c08259e36c..6116340976 100644 --- a/react_on_rails_pro/lib/react_on_rails_pro/request.rb +++ b/react_on_rails_pro/lib/react_on_rails_pro/request.rb @@ -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 @@ -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( @@ -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 diff --git a/react_on_rails_pro/packages/node-renderer/src/worker.ts b/react_on_rails_pro/packages/node-renderer/src/worker.ts index 3a7edb65a4..ed5dbe104a 100644 --- a/react_on_rails_pro/packages/node-renderer/src/worker.ts +++ b/react_on_rails_pro/packages/node-renderer/src/worker.ts @@ -125,6 +125,11 @@ export default function run(config: Partial) { 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