Read timeout when site is the server itself and platform is reloaded
reaper opened this issue · 1 comments
Hi,
I'm encountering a read timeout issue with ActiveResource when the site is set to the server itself, and the platform automatically reloads after a source code change.
- The
site
class variable is set to:http://localhost:3000/api/v1/brands.json
- I have a
BrandsController
with anindex
action that fetches and displays all brands usingBrand.all
. - There is no caching
Steps to Reproduce:
-
On the initial page load, everything works as expected.
-
After making a source code change, the platform auto-reloads.
-
Upon reloading the web page:
-
A read timeout occurs (logs show the
GET
request is made, but nothing happens afterward). -
However, if I directly access the API URL (
http://localhost:3000/api/v1/brands.json
), it successfully returns the brands in JSON format.
It seems like Brand.all
triggers the read timeout after the platform reloads, but I haven't been able to identify any relevant issues in the codebase.
Could you provide any advice on how to resolve this?
I've created a simple rails project to let you reproduce the issue: https://github.com/reaper/active-resource-read-timeout
Thanks!
Closing this issue, it was due to a thread lock from the Net::HTTP
get request.
Read https://guides.rubyonrails.org/threading_and_code_execution.html#permit-concurrent-loads, common quick resolution is to increase workers count in the puma/config.rb