Naming threads can be helpful for debugging (e.g. getting an overview of
what's running with `Thread.list.map(&:name)` or `ps -T -p PID`.
We noticed our reaper didn't have a name, so this commit adds one.
We've intentionally kept the name short (< 15 characters), since there
are platform limitations on the length of the underlying thread name.
Co-authored-by: John Hawthorn <jhawthorn@github.com>
By default, calling `inspect` on a record will yield a formatted string including just the `id`.
```ruby
Post.first.inspect #=> "#<Post id: 1>"
```
The attributes to be included in the output of `inspect` can be configured with
`ActiveRecord::Core#attributes_for_inspect`.
```ruby
Post.attributes_for_inspect = [:id, :title]
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
```
With the `attributes_for_inspect` set to `:all`, `inspect` will list all the record's attributes.
```ruby
Post.attributes_for_inspect = :all
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
```
Prior to this commit we were passing `allow_retry` and
`materialize_transactions` through from `execute_and_clear` to
`exec_cache`/`exec_no_cache`, but then doing nothing with them.
We've got a few internal queries using `execute_and_clear` (mostly via
`internal_exec_query`) that are passing `allow_retry: true` and
`materialize_transactions: false`. These calls will fail on connection
errors that might have been retryable. It's also possible they are
materializing transactions earlier than expected (although probably
not—most of the methods look like they would be called only by us,
always outside a transaction).
This commit forwards the arguments through to `with_raw_connection` so
the callers get the behavior they likely expect.
In e28f147329330e7ae55606e62ecc3de328431f0b the `show_exceptions`
default was updated to `:rescuable` in environments/test.rb.
The description still described the old default value (`false`), instead
of `:rescuable`.
This cache is used when url_for is called without a named route (ie.
when it's called with hash options). Eager loading avoids building the
cache on the first call and potentially allows the memory to be shared
via CoW on forking servers.
This commit addresses the following CI failure
https://buildkite.com/rails/rails/builds/101658#018ba903-f8d8-4187-929c-fc7996bb17f3
- Without this fix
```
$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ cd guides/bug_report_templates
$ ruby action_controller_gem.rb
... snip
/home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/runtime.rb:308:in `check_for_activated_spec!': You have already activated timeout 0.3.1, but your Gemfile requires timeout 0.4.1. Since timeout is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports timeout as a default gem. (Gem::LoadError)
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/runtime.rb:25:in `block in setup'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/spec_set.rb:155:in `each'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/spec_set.rb:155:in `each'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/runtime.rb:24:in `map'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/runtime.rb:24:in `setup'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/inline.rb:66:in `block in gemfile'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/settings.rb:131:in `temporary'
from /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.3.22/lib/bundler/inline.rb:50:in `gemfile'
from action_controller_gem.rb:5:in `<main>'
$
```
Follow up to previous commit where these procs were allows to be shared
between subclasses. This change allocates the procs as they are first
declared.
Just a wee bit of visualization changes to make it more explicitly clear what is being passed (a quoted number)
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
This commit separates inline attachments from normal attachments when
listing attachments in Action Mailer previews. For example, attachments
that were previously listed like
> Attachments: logo.png file1.pdf file2.pdf
will now be listed like
> Attachments: file1.pdf file2.pdf (Inline: logo.png)
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
When the webdrivers gem is not present (which is the default scenario in
Rails 7.1+), the Selenium `driver_path` starts out as `nil`. This means
the driver is located lazily, and deferred until a system test is run.
If parallel testing is used, this leads to a race condition, where each
worker process tries to resolve the driver simultaneously. The result is
an error as described in #49906.
This commit fixes the race condition by changing the implementation of
`Browser#preload`. The previous implementation worked when `driver_path`
was set to a Proc by the `webdrivers` gem, but doesn't work when the
`webdrivers` gem is not being used and the `driver_path` is `nil`.
`Browser#preload` now uses the `DriverFinder` utility provided by the
`selenium-webdriver` gem to eagerly resolve the driver path if needed.
This will ensures that `driver_path` is set before parallel test workers
are forked.
Fixes#49906.
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Along the same lines as https://github.com/rails/rails/pull/48295,
in multi-database applications it's helpful to have access to the pool
when debugging these timeouts. For example, we might send the connection
class and role along to an exception tracking system.
ConnectionTimeout was already set up to take a connection_pool, so this
commit passes it along as needed where we raise the error.
There was many public reports of 15-25% latency improvements for Rails
apps that did enable Ruby 3.2 YJIT, and in 3.3 it's even better.
Following https://github.com/ruby/ruby/pull/8705, in Ruby 3.3 YJIT
is paused instead of disabled by default, allowing us to enable it
from an initializer.
actiontext.js is compiled as ESM bundle instead of UMD bundle.
This leads to issues when trying to use ActionText with sprockets because the ESM bundle declares variables like they are scoped to the file but sprockets will see them as scoped globally.
This is a problem, in particular, if you want to mix actiontext with
turbo-rails.
The problem got introduced in https://github.com/rails/rails/pull/46447.
I traced valid compilation back to
https://github.com/rails/rails/pull/42895.
This commit mimic changes made in
https://github.com/rails/rails/pull/42895 to ActiveStorage:
Retains app/assets/javascripts/actiontext.js as a UMD package for backwards compatibility with
bundling in the asset pipeline, but also adds app/assets/javascripts/actiontext.esm.js for use
with ESM via importmap in the browser.
Related to https://github.com/rails/rails/pull/49802
Prior to this commit `with_raw_connection` would always mark the
connection as `@verified = true` after yielding it. But yielding a
connection is not enough to determine that a connection is healthy.
Marking a broken connection as verified can prevent further reconnects,
leaving us with a broken connection for longer than expected.
For example,
* Connection is broken and not verified
* Quote string succeeds, and marks the broken connection as verified
* Because the connection is verified, querying will not trigger a
reconnect
* Query fails and the connection is no longer verified
* Repeat ad infinitum (or until we reach a query with `allow_retry:
true`, or one that isn't preceded by a call to quote string)
This commit solves the problem by only marking the connection as
verified if we have definitively exercised that connection. This is
safer, but it does put more responsibility on each individual adapter.
If a call to `verified!` is missing things should still work OK, but
we'll end up pinging the connection more to see if it is active.
This adds `linguist-generated` and `linguist-vendored` attributes where
appropriate to suppress the files in diffs and exclude the files from
the project's language stats on GitHub.
See https://github.com/github/linguist for more information.
Prior to this commit, if `app/javascript/activestorage/index.js`
contained a syntax error, `JavascriptPackageTest` would still pass
because `system "yarn build"` would simply return `false` and the
compiled output would not change. This commit adds `exception: true` to
the `system` call so that an error will be raised if `yarn build` fails.
Also, since 6c96e1cd7bf3b7089c9b59b2ebeb35bfa6fb3f88, Active Storage
compiles an additional `app/assets/javascripts/activestorage.esm.js`
file. This commit adds an assertion for that file as well.
Prior to this commit, if `app/javascript/action_cable/index.js`
contained a syntax error, `JavascriptPackageTest` would still pass
because `system "yarn build"` would simply return `false` and the
compiled output would not change. This commit adds `exception: true` to
the `system` call so that an error will be raised if `yarn build` fails.
Also, since 4a23cb3415eac03d76623112576559a722d1f23d, Active Storage
compiles additional `app/assets/javascripts/actioncable.js` and
`app/assets/javascripts/actioncable.esm.js` files (with
`app/assets/javascripts/action_cable.js` being deprecated). This commit
adds assertions for those files as well.
Prior to this commit, if `app/javascript/rails-ujs/index.js`
contained a syntax error, `JavascriptPackageTest` would still pass
because `system "yarn build"` would simply return `false` and the
compiled output would not change. This commit adds `exception: true` to
the `system` call so that an error will be raised if `yarn build` fails.
This fixes a few issues with the formatting of the API documentation for
`ActionView::TestCase::Behavior::ClassMethods#register_parser`:
* Use `h4` headings instead of `h3` headings. SDoc renders method
signatures as `h3` headings, so subheadings such as "Examples" should
use `h4`.
* Replace "Arguments" heading with "Parameters". "Parameters" are
elements of function's signature, whereas "arguments" are elements of
a function call. The API documentation for other methods follows this
convention.
* Format parameters as term list.
* Fix indentation of pre-registered parser lists to render them as lists
instead of as code.
* Miscellaneous rewording, reorganization, and additional monospace
formatting.