Add Prosopite for N+1 query detection - #1358
Open
jaredlt wants to merge 3 commits into
Open
Conversation
Before, generated apps relied on strict_loading_by_default with the :n_plus_one_only mode for N+1 protection, which raises when an association is lazily loaded from a collection-loaded record. However, strict loading does not detect [all] N+1s. Now, [Prosopite] scans web requests & Sidekiq jobs in development and test via its middleware. Detections are logged in development and raise `Prosopite::NPlusOneQueriesError` in test, so new apps fail their test suite on N+1 queries that strict loading can't see. [all]: rails/rails#56094 [Prosopite]: https://github.com/charkost/prosopite
stevepolitodesign
left a comment
Contributor
There was a problem hiding this comment.
I think we'll want to remove these lines too:
suspenders/lib/templates/web.rb
Lines 283 to 284 in 25a6c4b
Contributor
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Contributor
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
stevepolitodesign
approved these changes
Aug 21, 2026
stevepolitodesign
left a comment
Contributor
There was a problem hiding this comment.
Sorry, just one more set of suggestions, then we're good!
Contributor
Author
|
@stevepolitodesign thanks for taking another look at this! All feedback should be addressed now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before, generated apps relied on
strict_loading_by_defaultwith the:n_plus_one_onlymode for N+1 protection, which raises when an association is lazily loaded from a collection-loaded record. However, strict loading does not detect all N+1s.Now, Prosopite scans web requests & Sidekiq jobs in development and test via its middleware. Detections are logged in development and raise
Prosopite::NPlusOneQueriesErrorin test, so new apps fail their test suite on N+1 queries that strict loading can't see.Closes: #1325