Skip to content

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

Merged
bf4 merged 1 commit intoJSONAPI-Resources:v0-11-devfrom
adamkiczula:bug-fix-class-caching
Feb 8, 2024
Merged

fix: add railtie to clear caches when code reloads#1448
bf4 merged 1 commit intoJSONAPI-Resources:v0-11-devfrom
adamkiczula:bug-fix-class-caching

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:

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 force-pushed the bug-fix-class-caching branch from 4cb43d9 to 8c8fd2a Compare February 8, 2024 19:15
@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
'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.

@bf4 bf4 merged commit bb00bbd into JSONAPI-Resources:v0-11-dev Feb 8, 2024
@lgebhardt
Copy link
Contributor

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