Repository navigation
task (vin-7729): defer kredis attributes via the active_model load hook - #1
Open
brenogazzola wants to merge 1 commit into
Open
brenogazzola wants to merge 1 commit into
brenogazzola wants to merge 1 commit into
Conversation
…load hook kredis 1.8.0 includes Kredis::Attributes into ActiveModel::Model from config.after_initialize, which loads ActiveModel::Model before the app is initialized and trips Rails' early-load guard (rails/rails#56201). Rails 7.1 added the :active_model load hook for exactly this (rails/rails#48698); it also gives eager-loaded ActiveModel::Model classes the attributes (rails#60). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NzgBdAKvgt4tYapPqqMKbR
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.
Card VIN-7729 · usado por FestaLab/festalab-app#9636
Este PR existe para documentar a branch. O festalab-app fixa o commit
0edf22b2dela no Gemfile, então nada precisa ser mergeado para o app funcionar.Por quê
O kredis 1.8.0, último release, inclui
Kredis::AttributesemActiveModel::Modeldentro de umconfig.after_initialize. ReferenciarActiveModel::Modelali carrega o Active Model antes de o app terminar de inicializar.O Rails edge passou a vigiar isso com o guard de load hooks (rails/rails#56201). Em todo boot sem eager load, ele loga um warning com backtrace. No festalab-app o guard está em
:raisenos testes, então com o kredis do rubygems todo boot de teste local quebraria comLoadError.O rails/kredis não tem fix nem issue sobre isso, e não recebe commit de código desde o 1.8.0.
O que muda
Um commit em
lib/kredis/railtie.rb: oafter_initializeviraActiveSupport.on_load(:active_model), o hook que rails/rails#48698 criou para isso. O Active Model roda esse hook quandoActiveModel::Modelcarrega, então o include acontece no mesmo momento, sem forçar o carregamento antes da hora. De quebra, classes carregadas por eager load também ganham as macros (rails#60).A branch parte da tag
v1.8.0do upstream. Omaindo upstream só tem commits de CI e Dependabot depois dela, então o código é exatamente o do gem 1.8.0 mais este commit.Cuidados
0edf22b2. O Bundler busca o commit direto no GitHub, e um commit que nenhuma branch alcança pode ser coletado.on_load. Aí o festalab-app volta para o gem do rubygems e esta branch pode ser apagada. O passo a passo está emdocs/env_development/dependency_updates.md, no festalab-app.O
maindeste fork foi sincronizado com orails/kredis:main(fast-forward, sem commits próprios) para este PR mostrar só a mudança.🤖 Generated with Claude Code
https://claude.ai/code/session_01NzgBdAKvgt4tYapPqqMKbR