Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionCable npm package renamed #132

Closed
dark-panda opened this issue Apr 1, 2020 · 4 comments
Closed

ActionCable npm package renamed #132

dark-panda opened this issue Apr 1, 2020 · 4 comments

Comments

@dark-panda
Copy link
Contributor

Bug Report

Rails 6.0 renamed the actioncable npm package to @rails/actioncable. We experience errors in production when precompiling our assets due to conflicts between these two versions of ActionCable.

Describe the bug

The npm package name for ActionCable needs to be updated. Not sure how this is done when it comes to renaming npm packages, as you may want compatibility with both the new @rails/actioncable package as well as the older actioncable package.

To Reproduce

Use Rails 6 and @rails/actioncable instead of actioncable.

Expected behavior

Shouldn't bomb out.

Screenshots or reproduction

N/A

Versions

StimulusReflex

  • Gem: 2.2.3
  • Node package: 2.2.3

External tools

  • Ruby: 2.6.5
  • Rails: 6.0.2.2
  • Node: 10.19.0

Browser

  • Browser Chrome
  • Version 80.0.3987.149
@andrewmcodes
Copy link
Contributor

@dark-panda can you tell us what the error was?

@leastbad
Copy link
Contributor

leastbad commented Apr 4, 2020

@hopsoft I feel like this needs to be flagged as high priority

@dark-panda
Copy link
Contributor Author

Error connecting controller

TypeError: Error connecting controller - TypeError: this.getConfig is not a function
    at createConsumer (action_cable.js:24)
    at T (consumer.js:27)
    at stimulus_reflex.js:49
    at Object.ie [as register] (stimulus_reflex.js:149)
    at t.value (info_controller.js:8)
    at e.connect (context.js:18)
    at e.connectContextForScope (module.js:34)
    at e.scopeConnected (router.js:80)
    at e.elementMatchedValue (scope_observer.js:42)
    at e.tokenMatched (value_list_observer.js:44)

Which in its pre-compiled form looks something akin to this:

https://github.com/rails/rails/blob/d03177ffbccb5b30217448d526f1e9aa1fa24297/actioncable/app/javascript/action_cable/index.js#L22

Or compiled:

createConsumer: function(url) {
  var ref;
  if (url == null) {
    url = (ref = this.getConfig("url")) != null ? ref : this.INTERNAL.default_mount_path;
}

It appears that it's using its dependency version of ActionCable 5.2.4, but since I upgraded to Rails 6 I'm using ActionCable 6.0.2.2 via the @rails/actioncable package. I could potentially downgrade or remove that package and just use the 5.2.4 version, but I'm not sure how that would play with the server version. Presumably what's going on here is that I've initialized with the 6.0 version of ActionCable while Stimulus Reflex is using its own version, and the two aren't playing nice. You should only be using one version of ActionCable at any given time.

@hopsoft
Copy link
Contributor

hopsoft commented Apr 14, 2020

Resolved by #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants