Closed afuno closed 4 years ago
@afuno Is this happening only locally? I think the issue is from Vue hot reloads. I'll add a fix that should prevent this duplication.
@mclintprojects No, the server has this problem too. I have a list of 99 items. In the console I see 9801 (99 * 99). But everything is fine on the backend.
I added another item to the list (now there are 100). Now I see 10000 (100 * 100) in the console.
@afuno This issue is definitely because of hot-reloading. Take a look at this. Because of it, each time Vue hot-reloads n subscriptions will be duplicated because the destroy hook is out-of-wack and my clean-up doesn't happen. The fix is to refresh the page.
Also this won't happen in production because there's no hot-reload.
@mclintprojects But this happens in production. My example about 99 items and 100 items is described from production.
But I agree - it looks like a hot update. Any ideas how to fix this?
I tried de-duplicating but the issue is from Vue. Refreshing the page seems to be the only thing that works.
Also by production I mean you build the app and run it. It still happens then?
Refreshing the page does not help, because after refreshing the country, subscriptions occur again.
Yes, of course, building and running the application.
@afuno I just published what I think is a patch for it. Try v2.3.1 and let me know how it goes.
@mclintprojects I have tested version 2.3.2 in production. Nothing has changed on this issue. All the same 10000 logs (100 * 100).
At this point I'll have to take a look at your code. I've fixed the duplication on my end so this is probably from yours.
Can we go to email (which is in your profile) for this?
@afuno Yes, kindly email me.
@mclintprojects I moved the subscription to the channel from each list item component to the root list component. This fixed the problem with "multiplying" subscriptions on the JS side. Thank you.
Rails 6.0.3.2 @rails/actioncable 6.0.3 @types/actioncable 5.2.3 actioncable-vue 2.3.0
I have some list. Each item in this list is wrapped in a component. Inside this component I have a subscription to the channel.
There are two items in the list. So there are two components within which the subscription takes place.
If we look at the server logs, we will see these two subscriptions:
But if look at the result of this code:
Then you can see the following:
That is, this code is executed 4 times.
mounted()
is executed twice as expected (once for each component)Why is this happening?
In other places, where there are more than 2 items (components) in the list, I get not duplication, but
item * n
, wheren
is more than 2 or even 4.