Commit Graph

640 Commits

Author SHA1 Message Date
Rafael Mendonça França
83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rafael Mendonça França
8160e25de0
Merge pull request #43591 from SkipKayhil/fix-actioncable-js-module
fix actioncable module field in package.json
2021-12-03 15:32:32 -05:00
Rafael Mendonça França
1fde031e89 Fix gemspec 2021-11-15 21:06:21 +00:00
Rafael Mendonça França
9195b7fd0a
Require MFA to release rails 2021-11-15 20:37:42 +00:00
Tanaka
6fee8be7fd
Add actioncable assets to gemspec.
actioncable.js and actioncable.esm.js is not included to gem package. It prevented us from using the action cable when using importmaps.

This adds the missing asset files to gem package.
2021-11-12 05:56:16 +09:00
Hartley McGuire
9dcd7099fa fix actioncable module field in package.json
The current module field points to a file that isn't included in the
files field of actioncable's package.json. This leads to errors when
trying to use actioncable in bundlers that use esm modules natively
(like Vite)
2021-11-03 21:24:20 -04:00
George Claghorn
426c69fd39 Action Cable: use non-deprecated entrypoint for JS package 2021-10-27 21:34:23 -04:00
Dan Spinosa
6d7c12274e
Client ensures subscribe command is confirmed. (#41581)
A SubscriptionGuarantor maintains a set of pending subscriptions,
resending the subscribe command unless and until the subscription
is confirmed or rejected by the server or cancelled client-side.

A race condition in the ActionCable server - where an unsubscribe
is sent, followed rapidly by a subscribe, but handled in the reverse
order - necessitates this enhancement.  Indeed, the subscriptions created
and torn down by Turbo Streams amplifies the existence of this race
condition.
2021-09-26 10:06:27 -07:00
Rafael Mendonça França
386ab893f6
Use regular memoization
`connection_gid` always return something so we don't need to use
`defined?`.
2021-09-23 19:23:27 -04:00
Rafael França
ddaf3b2cb3
Merge pull request #42574 from leastbad/connection_identifier
add connection_identifier to ConnectionStub
2021-09-23 19:19:07 -04:00
Rafael Mendonça França
d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França
9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
luizkowalski
868a63c695 Update guide and actioncable tests to use appropriate concurrent-ruby class 2021-09-15 17:50:49 +02:00
Xavier Noria
89801b2a43 Depend on ruby/debug, replacing Byebug
ruby/debug is a new debugger that is going to ship with CRuby.

It makes sense for Rails to switch to this one because that is
where the language is heading, and because Byebug is not fully
compatible with Zeitwerk. See

    https://github.com/deivid-rodriguez/byebug/issues/564

While ruby/debug has not been heavily tested with Zeitwerk,
casual usage seems to suggest it works without issues, including
explicit namespaces, which is where Byebug and Zeitwerk conflict.

Byebug is terrific, thanks a lot for all these years. ❤️
2021-09-08 17:35:41 +02:00
Jean Boussier
c91c266872 Enable Style/ExplicitBlockArgument cop
This reduce the stack size which is beneficial for
exceptions performance.

See: https://gist.github.com/byroot/cb3bcadcc3701c2518d002fb8d3a4e7a

However the cop is unsafe because it might change the block arity,
so it can run into some false positives.
2021-09-05 17:06:19 +02:00
Jose Galisteo
86ee45477c Fix rubocop offense 2021-09-04 20:48:35 +02:00
David Heinemeier Hansson
abc042cf9e Fix trailing whitespace 2021-09-04 19:47:32 +02:00
David Heinemeier Hansson
82e4432058
Javascript generator option with choices (#43160)
* Switch to a single controller option for choosing JavaScript approach

* Remove remnants of webpacker specific work within Rails

* No longer used

* Missing space

* Raise if unknown option is passed

* Style

* Use latest versions

* Make channels setup generic to all node setups

* Make Action Text installer work with any node package manager

* Explaining variables are not useless

* Rubocop pleasing

* Don't rely on Rails.root

Tests don't like it!

* Rubocopping

* Assume importmap

* No longer relevant

* Another cop

* Style

* Correct installation notice

* Add dependencies for action cable when adding a channel

* Fix paths to be relative to generator

* Just go straight to yarn, forget about binstub

* Fix tests

* Fixup installer, only yarn once

* Test generically with run

* Style

* Fix reference and reversibility

* Style

* Fix test

* Test pinning dependencies

* Remove extra space

* Add more tests

* Use latest dependencies

* Relegated this to controllers

* Refactor ChannelGenerator + more tests

Use a uniform level of abstraction
2021-09-04 11:53:57 +02:00
David Heinemeier Hansson
af7428c4ac
Replace webpack with importmapped Hotwire as default js (#42999)
* Turbolinks is being replaced with Hotwire

* Make --webpack opt-in

* Don't use specific webpacker installers any more in preparation for next Webpacker

* Update railties/lib/rails/app_updater.rb

Co-authored-by: Alex Ghiculescu <alex@tanda.co>

* Trailing whitespace

* Convert to Turbo data attribute for tracking

* Default is no webpack, no hotwire

* Swap out turbolinks references for hotwire

* Drop explicit return

* Only generate package.json if using webpack

* Only create package.json in webpack mode

* Only create app/javascript in webpack mode

* Generate correct style/js links based on js mode

* Fix tests from changed output format

Not sure why these are showing up in this PR, though.

* Rubocopping

* Stick with webpack for the test app for now

* Adjust tests

* Replace minitest-reporters with minitest-ci (#43016)

minitest-reporters is used to create junit xml reports on CI.

But when it loads before rails minitest plugin makes
`Rails::TestUnitReporter` not being added as a reporter.

minitest-ci is now only loaded at ci and does not interferes with
rails minitest plugins. And keeps junit reports workings

* Too heavy handed to actually run bundle

Just like we don't auto-migrate

* Pin js frameworks in importmap

Instead of having importmap preconfigure it.

* Match updated app/javascript path

* No need for the explaining comment

* Fixes test cases for replace webpack with importmapped Hotwire as default js (#42999)

* Fix rubocop issues

* Fix more railities test cases

* Fix plugin generator railties shared test cases

* Fix Action Text install generator asset pipeline spec

* They're modules, not files

* Let dev use the latest release as well

So we don't have to replace unexisting dev releases with latest release

* Make Webpack responsible for generating all the JS files it needs

Webpacker 6 has already moved from app/javascript to app/packs.

* Don't add rails/ujs by default any longer

All the ajax/form functionality has been superseded by Turbo. The rest lives in a weird inbetween land we need to address through other means.

* Use new importmap location

* Switch to using turbo-rails and stimulus-rails directly

The hotwire-rails gem does not offer enough value for its indirection

* Use latest Webpacker

* Prevent version resolution requests from getting swallowed

* Use ESM syntax for imports

* Move management of yarn, package.json, etc to Webpacker 6

* Update for Webpacker 6

* Move bin/setup addition to Webpacker as well

* Remove dead tests

* Bump to Webpacker 6.0.0.rc.2

* No longer relevant given the new default is no webpacker

* Rely on Webpacker 6

* No longer relevant

* No longer relevant

* Make cable channel generator work for both webpacker and importmap setups

* Fix tests

* For tests testing importmap way

* Use Webpacker 6 dummy

* RuboCopping

* One more bump to fix webpack-dev-server

* Another bump. Hopefully the last one!

* Also enough to not want turbo tracking on

* Fix tests

* Latest

* Fix tests

* Fix more tests

* Fix tests

Co-authored-by: Alex Ghiculescu <alex@tanda.co>
Co-authored-by: André Luis Leal Cardoso Junior <andrehjr@gmail.com>
Co-authored-by: Abhay Nikam <nikam.abhay1@gmail.com>
Co-authored-by: Guillermo Iguaran <guilleiguaran@gmail.com>
2021-08-26 10:39:36 +02:00
David Heinemeier Hansson
4a23cb3415
Output Action Cable JS without transpiling and as ESM (#42856)
* Output Action Cable JS without transpiling and as ESM

* Retain umd version under the old name, generate ESM version + duplicate under new name

* Precompile JavaScripts for direct asset pipeline use

* We've dropped support for IE11

* Include deprecation notice for the old file reference

Thanks @rafaelfranca 👍

* Allow app to opt out of precompiling actioncable js assets

cc @rafaelfranca

* Add changelog entries
2021-08-06 14:00:43 +02:00
Rafael Mendonça França
90868dab14
Allow testing action cable with a different redis port 2021-08-04 18:17:47 -04:00
Rafael Mendonça França
18707ab17f
Standardize nodoc comments 2021-07-29 21:18:07 +00:00
Ryuta Kamizono
e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
Jean Boussier
cce46f8db1
Merge pull request #42459 from ghiculescu/patch-2
Log a warning when assertions are incorrectly nested and errors are raised
2021-07-12 19:05:39 +02:00
Alex Ghiculescu
4b42beb3b8 Log a warning when assertions are incorrectly nested and errors are raised
Follow up to https://github.com/rails/rails/pull/37313

- Adds regression tests
- Logs a warning in cases where assertions are nested in a way that's likely to be confusing
2021-07-12 10:37:43 -05:00
J Smith
460735e03f Truncate more ActionCable broadcast messages to 300 chars
Truncation to ActionCable logging was added way back in 2016, but here's
another location where the logging messages can get out of hand.
2021-07-07 14:52:29 -03:00
Dirkjan Bussink
0523532a3c
Always use OpenSSL constants for Digest operations
As also previously discussed in
https://github.com/rails/rails/pull/40770#issuecomment-748347066, this
moves the usage of Digest constants to always use the OpenSSL version of
those Digest implementations.
2021-06-30 13:57:54 +02:00
leastbad
b18e6ba6bd add connection_identifier assertion to ConnectionStub test 2021-06-24 07:53:02 -04:00
leastbad
5d61773812 ConnectionStub identifiers are methods, not ivars 2021-06-24 04:48:52 -04:00
leastbad
d573fb11d7 add connection_identifier to ConnectionStub 2021-06-23 06:19:07 -04:00
Matheus Richard
c3d7794f16 Replace map + compact with filter_map 2021-04-22 22:08:34 -03:00
John Bachir
267e1d25dc Add name to ActionCable threads
To assist in various debugging scenarios, such as [tracking which types of threads are using db connections][0]

Thread names will now be "ActionCable-worker-N" instead of "worker-N".

This is safe for all ruby versions. In versions which do not have thread names, [concurrent-ruby does not attempt to add the name][1]

In the environment I happened to be testing in:

```ruby
e = Concurrent::ThreadPoolExecutor.new(name: 'ActionCable', min_threads: 2, max_threads: 2)
e.post{sleep 100}
e.post{sleep 100}
Thread.list.map(&:name)
```

[0] https://github.com/puma/puma/issues/1512#issuecomment-756760388
[1] https://github.com/ruby-concurrency/concurrent-ruby/blob/master/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb#L312
2021-04-14 11:24:37 -07:00
Vladislav
d264276288 RemoteConnection#disconnect: fix ArgumentError on ruby 3.0 2021-04-02 12:24:54 -04:00
Carlos Antonio da Silva
ca06a9ff41 Refactor to use model instead of record as argument in Action Cable
We refer to `model` elsewhere in Action Cable's  implementation, so use
the same in `stream_or_reject_for` as well to keep the consistency.

Simplify the docs for the method to remove the usage "intention"
(that's not up to us) and mention it rejects the "subscription", not
the "connection".
2021-02-25 11:21:19 -03:00
Jonathan Hefner
167f5c8065 Fix inline code markup [ci-skip]
RDoc Markup does not support backticks the way Markdown does to mark up
inline code.  Additionally, `<tt>` must be used to mark up inline code
that includes spaces or certain punctuation characters (e.g. quotes).
2021-02-14 11:20:35 -06:00
Rafael Mendonça França
1b455e2e9d
Rails 6.2 is now Rails 7.0
We have big plans for the next version of Rails and that
require big versions.
2021-02-04 16:47:16 +00:00
Rafael Mendonça França
6487836af8
Rails 7 requires Ruby 2.7 and prefer Ruby 3+
The code cleanup is comming in later commits but this
already remove support to Ruby < 2.7.
2021-02-04 16:34:53 +00:00
Jonathan Hefner
cc9a9e8503 Prevent thundering herd of Action Cable clients
This commit makes a few changes to the Action Cable client to prevent a
"thundering herd" of client reconnects after server connectivity loss:

* The client will wait a random amount between 1x and 3x of the stale
  threshold after the server's last ping before making the first
  reconnection attempt.
* Subsequent reconnection attempts now use exponential backoff instead
  of logarithmic backoff.  To allow the delay between reconnection
  attempts to increase slowly at first, the default exponentiation base
  is < 2.
* Random jitter is applied to each delay between reconnection attempts.

Co-authored-by: John Williams <john@veloshots.com>
2021-02-02 10:43:05 -06:00
alea12
4858c9fa2d Update ActionCable docs [ci skip] 2021-01-08 19:08:55 +09:00
Ryuta Kamizono
2b0b5a75c0 Bump license years to 2021 [ci skip] 2021-01-01 12:21:20 +09:00
Rafael Mendonça França
59f7f5889e
Start Rails 6.2 development 🎉 2020-12-03 01:35:29 +00:00
Daniel Colson
d092c133c7
Do not allow subscribing to Base channel
Closes #40482

Prior to this commit it was possible to subscribe with
`ActionCable::Channel::Base` as the subscription class. While it doesn't
seem possible to exploit this in away way, it also doesn't seem like
something we need to allow.

This commit swaps [Module#>=][gte] with [Module#>][gt] to prevent
subscribing to a channel when `ActionCable::Channel::Base` is the
subscription class.

[gte]: https://ruby-doc.org/core-2.5.3/Module.html#method-i-3E-3D
[gt]: https://ruby-doc.org/core-2.5.3/Module.html#method-i-3E
2020-11-24 22:30:03 -05:00
Jonathan Hefner
949e4587d5 Allow missing Action Cable config
Since #37850, `config_for` returns `nil` instead of an empty Hash when
a config file does not contain configuration for the specified
environment.  Thus, the return value should be converted to a Hash
before calling `with_indifferent_access`.

Fixes #40548.
2020-11-06 11:45:51 -06:00
Rafael Mendonça França
8389f9902c
Preparing for 6.1.0.rc1 release 2020-11-02 21:12:47 +00:00
Jonathan Hefner
fd3fd618f4 Add gitattributes for vendored and generated files [ci-skip]
The `linguist-vendored` attribute excludes the specified file from the
project's language stats on GitHub.  The `linguist-generated` attribute
does the same, and also suppresses that file in diffs on GitHub.

See https://github.com/github/linguist for more information.
2020-10-04 16:44:37 -05:00
Rafael França
1eade80dd6
Merge pull request #39123 from tannakartikey/actioncable_logger_docs
Added docs for client-side logger
2020-07-06 14:28:43 -04:00
Kartikey Tanna
e0ec24e3c0 Added an example of logging 2020-07-06 23:32:55 +05:30
Ryuta Kamizono
528b62e386 Address to false negative for Performance/DeletePrefix,DeleteSuffix
Follow up to c07dff72278fb7f2a3c4c71212a0773a2b25c790.

Actually it is not the cop's fault, but we mistakenly use `^`, `$`, and
`\Z` in much places, the cop doesn't correct those conservatively.

I've checked all those usage and replaced all safe ones.
2020-06-14 13:04:47 +09:00
Tim Craft
7f41ab2b0e Use indifferent access for config hash in actioncable postgresql test 2020-06-10 13:52:43 +01:00
Étienne Barrié
f1cef4c9ca Remove invalid autoloads in top-level Rails modules 2020-06-08 17:21:26 -04:00