Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add railtie to clear caches when code reloads #1448

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

adamkiczula
Copy link

@adamkiczula adamkiczula commented Feb 8, 2024

fixes #1439

This adds a railtie hook to clean up the JSONAPI::Resource caches when code reloads so that we don't have stale references to classes lying around.
I'm not sure how to test this one in a test suite, but there's a reproduction script in #1439 that passes with this.

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist. Class caching is too aggressive in dev #1439
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change. (see script in Class caching is too aggressive in dev #1439, happy to incorporate into CI if you have ideas on how to do that)

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

@adamkiczula adamkiczula changed the title fix: skip class caching if Rails has it disabled fix: add railtie to clear caches when code reloads Feb 8, 2024
@@ -26,6 +26,10 @@ class Railtie < ::Rails::Railtie
'by setting `warn_on_eager_loading_disabled` to false.'
end
end
config.to_prepare do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noting that this is related to the same issue we were trying to address in #1440 and #1434

@bf4 bf4 merged commit bb00bbd into cerebris:v0-11-dev Feb 8, 2024
36 checks passed
@lgebhardt
Copy link
Member

Thanks @adamkiczula!

@adamkiczula adamkiczula deleted the bug-fix-class-caching branch February 8, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants