Disconnect Hanami::Model
directly inside Hanami.boot
#760
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.
This supposed to be fixed by #748 but the problem is still there.
I have a project on Heroku, running with Puma:
During the deploy/reboot process, stale connections used to stay around. That used to cause intermittent errors for the requests that were hitting the database. Specifically, the connection failed to read data from the socket:
Why #748 didn't fixed the problem? Because
Hanami::Model.disconnect
used to be invoked in aprepare
block of the"model"
component. Theprepare
block is only evaluated once only when the component wasn't resolved yet.During the reboot, we already have all the components resolved, so the
prepare
block wasn't invoked anymore.I also tried to write a
"model.disconnector"
component to be invoked every time (it usesrun
instead ofresolve
), but for some reason it won't work as well.So I ended to include the
Hanami::Model.disconnect
call insideHanami.boot
. This fixes the problem./cc @hanami/core