bellycard / napa

A simple framework for building APIs with Grape
Other
329 stars 72 forks source link

Allow eager autoloading #199

Open atomic-hedgehog opened 9 years ago

atomic-hedgehog commented 9 years ago

In a multi-threaded environment we are seeing circular dependency exceptions (usually around representer classes).

Rails suffers from the same problem, but in production a rails app will use eager autoloading to prevent it. However, this doesn't seem to hold for Napa since we are seeing the same issue in production.

I have spent some time trying to find a way to force eager autoloading in Napa, but nothing seemed to work. Is there already a simple way to enable eager autoloading or will this require an update to Napa?

darbyfrey commented 9 years ago

We've actually run into this issue sporadically as well, but it hasn't been in a repeatable way that we could debug. Have you been able to construct a repeatable scenario for this? If so, I'd love to find out how you did it so we could trace down the issue.

Also, what server are you running on in production?

atomic-hedgehog commented 9 years ago

We have an Angular app for our front end, so that was where we first noticed it (lots of concurrent calls to the API server). We are using SwaggerUI, and I can consistently cause the error by spamming GET requests through there (to an API wrapping a simple ActiveRecord model without much business logic).

Our app is still under heavy development and our production deploys are still internal test sites, so we are using webrick for both development and production. I haven't tried other web servers yet, but we are planning to stick with multithreaded servers.