question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stop watching connection state when onNext() is called

See original GitHub issue

So I have discovered a weird bug:

I have subscribed to messages like this inside an injectible service:

this._stompMessages = this._stompService.subscribe('/user/queue/messages'); this.subscription = this._stompMessages.subscribe(this.on_next);

When the on_next method gets called I want to push something to a BehaviorSubject that is a property of this service. So inside on_next I do something like this:

this._messages.next(this._messages.getValue().concat(value));

This causes an UNSUBSCRIBE command, but why?

“Stop watching connection state (for /user/queue/messages)” ng2-stompjs.es5.js:58 “Will unsubscribe from /user/queue/messages at Stomp” ng2-stompjs.es5.js:58 ">>> UNSUBSCRIBE id:sub-0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kum-deepakcommented, May 31, 2018

I had a look at your log file. Please try wrapping the code within onNext in a try-catch block, similar to the following:

  public onNext = (message: Message) => {
    try {
      console.log(JSON.parse(message.body));
      if (JSON.parse(message.body) != 0) {
        if (...)
      .....
      }
      else {
      .....
      }
    } catch (e) {
      // Handle it properly
      console.error(e);
    }
  };

Let me know if it solves your issue.

0reactions
Fridthjofcommented, May 31, 2018

I don’t know if that was the thing that made it work, since i did some smaller tries of things.

But it works now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Behaviour of onNext and onComplete - Stack Overflow
First I started to just call onComplete, because in the end the observable does its job and completes. But then of course onNext...
Read more >
Chapter 1. Reactive Programming with RxJava - O'Reilly
The onNext() method might never be called or might be called once, many, or infinite times. The onError() and onCompleted() are terminal events, ......
Read more >
How (not) to use Reactive Streams in Java 9+ | by Jacek Kunicki
Since the implementation is synchronous, there's an issue with unbounded recursion resulting from the subscription's request() calling the ...
Read more >
Reactor 3 Reference Guide
In this case, the Disposable interface represents the fact that the subscription can be cancelled, by calling its dispose() method. For a Flux ......
Read more >
State Management In Next.js - Smashing Magazine
If you believe there is a relevant pattern to be considered, I look forward to seeing you in the comments section! React Core...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found