Fix React Hooks send double ATTACH
message action and get doubled rewind messages when using options on v2
#1704
Labels
bug
Something isn't working. It's clear that this does need to be fixed.
When using
ChannelProvider
with any sort of options:It causes channel to send double ATTACH messages:

If using any rewind options
{ params: { rewind: '1' } }
, this then leads to us getting last N rewind messages twice, so we end up with duplicates.Issue appeared on v2 after transitioning to
ChannelProvider
implementation in #1620, merge commit ec95b59This is caused when
ChannelProvider
calls.setOptions()
on the channel in itsuseEffect
hookably-js/src/platform/react-hooks/src/ChannelProvider.tsx
Line 48 in af0f3f1
useChannel
hook (for example, providing a listener touseChannel
hook causes it to attach). Calling.setOptions()
in this case triggers reattachment and for some reason causes doubleATTACH
message being sent, both with the same rewind options (even though first attachment should've been done without any options - they were not set yet).This is probably an underlying issue with ably-js itself, it should not send double
ATTACH
messages like in this case. Probably the expected behaviour would be to send firstATTACH
message without any options (triggered fromuseChannel
hook when no options are set), and then a secondATTACH
message with options from.setOptions()
call.┆Issue is synchronized with this Jira Bug by Unito
The text was updated successfully, but these errors were encountered: