Commit Graph

89885 Commits

Author SHA1 Message Date
John Hawthorn
27c28ce046
Merge pull request #49960 from jhawthorn/eager_load_as_callbacks
Eager load ActiveSupport::Callback procs
2023-11-08 11:27:01 -08:00
Daniel Colson
85790302c6
Name the connection pool reaper thread
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>
2023-11-08 14:23:52 -05:00
Andrew Novoselac
e50182a42c Make the output of ActiveRecord::Core#inspect configurable.
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">"
```
2023-11-08 14:23:16 -05:00
Daniel Colson
aecca3d2d4
Pass along with_raw_connection params in PG adapter
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.
2023-11-08 13:09:13 -05:00
Jonathan Hefner
7a3a432c2a
Merge pull request #49969 from aidanharan/remove-old-test-job
ActiveJob: Remove unused `QueueAsJob` test job

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
2023-11-08 11:03:31 -06:00
Jonathan Hefner
8b8cef49a9
Merge pull request #49967 from p8/railties/test-env-show-exceptions-comment
Update description for show_exceptions in environments/test.rb
2023-11-08 10:58:47 -06:00
Aidan Haran
6dd980fed0 Remove unused test job 2023-11-08 16:33:53 +00:00
Matthew Draper
e3deb75fad
Merge pull request #49811 from composerinteralia/verify-only-when-connection-exercised
Prevent marking broken connections as verified
2023-11-09 00:56:56 +10:30
Petrik
155ec680bb Update description for show_exceptions in environments/test.rb
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`.
2023-11-08 13:58:58 +01:00
John Hawthorn
591c4aa1ea Eager load Journey Formatter cache
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.
2023-11-07 20:16:43 -08:00
Yasuo Honda
939fd3bc41
Merge pull request #49962 from yahonda/timeout_041
Bump timeout to 0.4.1
2023-11-08 11:24:03 +09:00
Yasuo Honda
36c49b3cf5 Bump timeout to 0.4.1
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>'
$
```
2023-11-08 11:01:58 +09:00
John Hawthorn
42ad4d6b0b Eager load ActiveSupport::Callback procs
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.
2023-11-07 16:19:00 -08:00
Jonathan Hefner
253cddd92d
Merge pull request #49957 from gjtorikian/patch-1
Update documentation in asset_tag_helper.rb [ci-skip]
2023-11-07 16:48:53 -06:00
Garen Torikian
94de154a23 Update documentation in asset_tag_helper.rb
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>
2023-11-07 16:42:59 -06:00
Jonathan Hefner
14294c0cc8
Merge pull request #49828 from c960657/preview-interceptor-inline
Ignore inline attachments and show attached emails in attachment list
2023-11-07 16:14:30 -06:00
Christian Schmidt
ff2e38ccc5 List inline attachments separately in AM previews
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>
2023-11-07 15:58:44 -06:00
John Hawthorn
e956aafbc1
Merge pull request #49944 from composerinteralia/connectiontimeouterror-pool
Add connection pool to connection timeout errors
2023-11-07 10:33:03 -08:00
Jonathan Hefner
0157819d08
Merge pull request #48782 from c960657/preview-smtp-envelope
Only show SMTP envelope recipient when relevant
2023-11-07 12:00:25 -06:00
Eileen M. Uchitelle
2f34889320
Merge pull request #49919 from jonathanhefner/linter-accept-username-as-author
Accept username as valid author name in `CHANGELOG`
2023-11-07 12:56:02 -05:00
Christian Schmidt
e5481edb8b Only show SMTP-To if different from To+Cc+Bcc
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-11-07 11:44:55 -06:00
Jonathan Hefner
3162afe959
Merge pull request #49908 from mattbrictson/bugs/chromedriver-race-cond
Preload Selenium driver_path before parallelizing system tests
2023-11-07 11:41:13 -06:00
Matt Brictson
e7d743b8ac Preload Selenium driver_path before parallelizing system tests
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>
2023-11-07 11:15:18 -06:00
Daniel Colson
846bf52c89
Add connection pool to connection timeout errors
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.
2023-11-07 07:34:04 -05:00
Jean Boussier
d53ef2c180
Merge pull request #49948 from ghiculescu/patch-12
Fix grammer in railties changelog
2023-11-07 10:59:53 +01:00
Jean Boussier
7f8a413a93 Delete duplicated file 2023-11-07 10:59:23 +01:00
Alex Ghiculescu
644ee2fb0b
Fix grammer in railties changelog
cc @byroot
2023-11-07 19:31:09 +10:00
Jean Boussier
632bcb3918
Merge pull request #49947 from Shopify/enable-yjit
Enable YJIT by default if running Ruby 3.3+
2023-11-07 10:00:50 +01:00
Jean Boussier
c29cda2fec Enable YJIT by default if running Ruby 3.3+
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.
2023-11-07 09:26:29 +01:00
Matias Grunberg
2dbcb3df33 fix using actiontext.js in sprocket
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.
2023-11-07 00:36:53 -03:00
Jonathan Hefner
488a7ce188
Merge pull request #49936 from seanpdoyle/ar-nested-attributes-default
Docs: Replace "off" with `false` [ci skip]

Co-authored-by: Petrik <petrik@deheus.net>
2023-11-06 11:27:02 -06:00
Sean Doyle
1567419fc3 Docs: Replace "off" with false [ci skip]
Replace a reference to a default `"off"` value in the
`ActiveRecord::NestedAttributes` module with the actual default value:
`false`.
2023-11-06 12:22:55 -05:00
Daniel Colson
a180823195
Prevent marking broken connections as verified
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.
2023-11-06 11:23:37 -05:00
Jonathan Hefner
8d778e0708
Merge pull request #49904 from MaicolBen/bug/infinite-changed
Don't mark Float::INFINITY as changed if didn't
2023-11-06 08:47:29 -06:00
MaicolBen
19869e765e Don't mark Float::INFINITY as changed when reassigning it
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-11-06 08:33:39 -06:00
Jean Boussier
9c8585156e
Merge pull request #49934 from fatkodima/fix-pg-uuid-changed-formats
Fix PostgreSQL `Uuid#change?` to ignore uuid's value formatting
2023-11-06 13:10:48 +01:00
fatkodima
2c98042440 Fix PostgreSQL Uuid#change? to ignore uuid's value formatting 2023-11-06 13:57:59 +02:00
Matthew Draper
c0e67e6547
Merge pull request #49802 from composerinteralia/postgres-unrecoverable-connection-error
Recover from failed connections in PostgreSQL
2023-11-06 17:26:11 +10:30
yoshiki masubuchi
2655cad028 Improve action_mailbox_basics.md 2023-11-06 08:48:55 +09:00
Jonathan Hefner
995092e7f6
Merge pull request #49933 from jonathanhefner/gitattributes-update-all
Update `.gitattributes` for generated JavaScript [ci-skip]
2023-11-05 15:51:15 -06:00
Jonathan Hefner
4dcd6ba8d3 Update .gitattributes for generated JavaScript [ci-skip]
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.
2023-11-05 15:48:08 -06:00
Jonathan Hefner
3764d7bd16
Merge pull request #49932 from jonathanhefner/action_text-javascript_package_test
Add `JavascriptPackageTest` for Action Text
2023-11-05 15:47:40 -06:00
Jonathan Hefner
a93771cb0d Add JavascriptPackageTest for Action Text
This mirrors the existing `JavascriptPackageTest` tests for UJS, Action
Cable, and Active Storage.
2023-11-05 15:28:14 -06:00
Jonathan Hefner
e7d0ce9045
Merge pull request #49931 from jonathanhefner/javascript_package_test-update-all
Update `JavascriptPackageTest` tests
2023-11-05 15:27:45 -06:00
Jonathan Hefner
28e976b6aa Update JavascriptPackageTest for Active Storage
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.
2023-11-05 15:13:33 -06:00
Jonathan Hefner
8e213f72dd Update JavascriptPackageTest for Action Cable
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.
2023-11-05 15:13:30 -06:00
Jonathan Hefner
859cab5607 Fail on error in JavascriptPackageTest for UJS
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.
2023-11-05 15:12:22 -06:00
Jonathan Hefner
febd21da34
Merge pull request #49923 from akhilgkrishnan/add-api-reference-to-view-helper
API documentation reference added to view helper [ci skip]
2023-11-04 23:01:06 -05:00
Jonathan Hefner
8a304dcfc9
Merge pull request #49924 from jonathanhefner/action_view-register_parser-doc-formatting
Fix formatting of `AV::TestCase.register_parser` doc [ci-skip]
2023-11-04 23:00:41 -05:00
Jonathan Hefner
916c419dad Fix formatting of AV::TestCase.register_parser doc [ci-skip]
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.
2023-11-04 22:55:13 -05:00