anycable / anycable-client

AnyCable / Action Cable JavaScript client for web, Node.js & React Native
MIT License
97 stars 15 forks source link

Fix: Hub entry key issue #13

Closed lokkirill closed 2 years ago

lokkirill commented 2 years ago

Hi!

Small problem description: We have two channels in our projects now: NotificationChannel and ConversationChannel. I've faced a problem with parallel subscriptions to both of this channels on page loading on messages page.

After some debug I realized, that for both of channel entries Hub uses same key: [object Object] :D So in this PR I've added simple key generation (stringified object of channel identifier and params) and it even must be uniq.

Also added new test case

lokkirill commented 2 years ago

There also was an issue with channel disconnect: it couldn't disconnect because of entity refs increments in one Entity instance because of this Hub entity key issue - so on channel.disconnect() entry's refs value was 2 and after unmark() it still wasn't isFree()

palkan commented 2 years ago

Thanks for the report and a test case (though it passed without any changes, I guess, since we run tests in the Node env, not in the browser).

I decided to go with a WeakMap.