Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
## Next Release
## Unreleased

* Fixed crashes when a client disconnects mid-handshake (e.g. on connect timeout). Previously, `Errno::EPIPE` raised in `Spring::Server#serve` or `Spring::Application#serve` would propagate up through the accept loop and kill the process, leaving a stale socket that broke every subsequent client. Both crash sites are now rescued, including writes that happen inside the `rescue Exception` handler in `Application#serve` while reporting an earlier failure to the gone client.

* Eagerly autoload framework base classes (`ActionMailer::Base`,
`ActionController::Base`, `ActionController::API`) at the end of preload
so their `ActiveSupport.on_load` hooks fire in the parent process.
Without this, the reloader probe in `#serve` materializes Rails
internals (notably ActionView's `CacheExpiry::ViewReloader`) in a
half-initialized state and triggers an expensive `FileUpdateChecker`
rebuild on every `prepend_view_path` inside each fork. See
rails/rails#51308 for the lazy-init contract this aligns with.

## 4.4.0

* Revert the removal of UTF-8 force encoding in JSON loading.
Expand Down
14 changes: 14 additions & 0 deletions lib/spring/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def preload
require Spring.application_root_path.join("config", "environment")

invoke_after_environment_load_callbacks
preload_framework_base_classes

disconnect_database

Expand Down Expand Up @@ -144,6 +145,19 @@ def preload
end
end

# Eagerly autoload framework base classes
FRAMEWORK_BASE_CLASSES = %w[
ActionMailer::Base
ActionController::Base
ActionController::API
].freeze

def preload_framework_base_classes
FRAMEWORK_BASE_CLASSES.each do |const|
Object.const_get(const) if Object.const_defined?(const)
end
end

def eager_preload
with_pty do
# we can't see stderr and there could be issues when it's overflown
Expand Down
Loading