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

Null-pointer when calling subscribe() #462

Open
sbaechler opened this issue Jul 13, 2022 · 5 comments
Open

Null-pointer when calling subscribe() #462

sbaechler opened this issue Jul 13, 2022 · 5 comments

Comments

@sbaechler
Copy link

I was getting a TypeError: Cannot read properties of undefined (reading 'subscribe'):

sentry-error

We pause subscriptions before a batch action that can trigger mutliple websocket events and resume them once the batch is done. In that case that was after 2 seconds.

For this we call unsubscribe on the subscriptions and subscribe shortly after.

I guess for some reason _disposeStompHandler was called in between.

@kum-deepak
Copy link
Member

Please enable debug and attach the full console output.

@sbaechler
Copy link
Author

I would need some time to reproduce this issue. Since it was reported by Sentry means that it happened in a production environment. I'll still have to figure out why the connection was disposed.

From what I could see from the source code, Stomp does not check if _stompHandler is defined in the subscribe method.

I would add an invariant there that produces a better error message.

@rumit0406
Copy link

@sbaechler were you able to solve the problem? If yes, please share how did you did it as I'm also facing the same issue.

@v1talii-dev
Copy link

Are there any updates on this issue?

@kum-deepak
Copy link
Member

A long discussion on seemingly a simple issue.

The underlying STOMP connection is not guaranteed to be always there - it may vanish at any time. The reconnection logic will trigger upon discovering the loss of connection, however, there would be spans without an underlying connection. In addition, the subscriptions do not survive disconnects and need to be reestablished on successful reconnects.

So, the user code must check and should be willing to handle these scenarios. This can make the user code quite clumsy.

To simplify these, a few years back I wrote a wrapper for this library https://github.com/stomp-js/rx-stomp. This version exposes an alternate semantics:

In my opinion when using from a long-running application (an App or SPA) rx-stomp is a better fit.

Based on feedback, I may write an article in greater depth.

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

No branches or pull requests

4 participants