absinthe-graphql / absinthe-socket

Core JavaScript support for Absinthe WS-based operations
MIT License
148 stars 75 forks source link

Observer is not attached to notifier #56

Open jesusbotella opened 3 years ago

jesusbotella commented 3 years ago

Hello everyone! I'm using @absinthe/socket-apollo-link 0.2.1 (with phoenix 1.5.7), and this error triggers quite frequently after refreshing socket connections.

In our platform, an active socket connection is closed right after the token expires, we refresh the token, and then reconnect it again.

Seems like whenever a socket connection is closed, socket-apollo-link refreshes those observables, but then when Apollo tries to unsubscribe because components are re-rendering after the credentials change, socket-apollo-link does not find those previously registered observables that Apollo has but the notifier is still active.

It doesn't always happen, but I'm receiving error reports quite often because of that, so probably there's a race condition? Do I need to call Apollo's reFetchObservableQueries after reconnecting the socket to solve this? 🤔

Thank you!