angular: Error: Uncaught (in promise): ObjectUnsubscribedError

What could be the reason for the error that you can see in the attached screenshots.

I think it’s not reproducible in a plunkr, but I’ll try to describe what I’m doing. I’ve a child component that is emitting an event to a parent component. This parent component has an event handler for this event and when I’m calling it, I just show a modal dialog which is show some details.

  showQuestionDetails(question) {
    this.selectedQuestion = question;
    this.materialize.showDialog('questionDetailsDialog');
  }

  closeQuestionDetailsDialog() {
    this.selectedQuestion = undefined;
    this.materialize.closeDialog('questionDetailsDialog');
  }

What is happening inside the showDialog function is just the following code:

$(`#${dialogId}`).openModal();

And the closeDialog function just calls closeModal and that’s everything.

After I closed the dialog I’m getting this error messages.

bildschirmfoto 2016-04-14 um 21 05 59 bildschirmfoto 2016-04-14 um 21 05 26

Event when I remove the component that shows the details and I just show an empty dialog which has nothing todo with Angular 2, I’m getting this error. What could be the reason for this?

The component that I use for showing the dialog is MaterializeCSS and the dialog will be shown via jQuery. I hope that Angular2 has no problem with jQuery, isn’t it?

*** Please tell us about your environment: *** Angular version: 2.0.0-beta.15 ( It’s the same with Beta 14 and 13) Browser: Chrome Canary the latest Language: ES6 transpiled with babel

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I reproduced the error in this fiddle with these few lines

var obs = new Rx.Subject();
obs.next('Some value');
obs.complete();
obs.next('Some value');

I googled the error and I found this question, I’m pretty sure you did google also, right? I also found this spec on RxJS repo that helped me to reproduce it.

I think it’s not reproducible in a plunkr

At least you tried to reproduce it, right? You’re no providing any information, and considering that I reproduced the same error without angular2 being involved I can say this is not a bug, you’re doing something weird in your code. But who knows… there’s no repro of it.

You really need to read the contributing guide, I also recommend you to watch this talk.

If you want help, you need to help others to help you. And look it for in the right place, github is not the right place when it comes to users errors. You’ll get help faster if you look for it where you should.

@zoechi Thanks for your answer ! Actually it’s 100% the same issue, but, for me, the answer given don’t really fix it (despite the original author was satisfied). Maybe you could consider my point of view as a feature request (but i still think it’s rather a bug).

I’m aware about nested routing /..., matter is what happens when the user use an url who is not filled by the RouterConfig. From my experience, using the HashLocationStrategy, the application crash with the promise error from this issue. I’m asking why the useAsDefault:true parameter on a route is not used to handle urls which are not explicitly created into the router.

The idea beside my point of view is to natively provide a “404-like” feature into the ng2 route system. I think it’s a bug since useAsDefault should logically fill this purpose… The original author called a wrong url, and the ng2 framework brutally crashed. It would be so much better to get redirected into the default route instead (the 404-like). He would have understood it was a bad path call in few seconds by himself. It’s even more relevant about the final user, he got no way to understood why the site crashed.

I hope my question is a bit more understandable this time 😂 !

@ericmartinezr @janbaer The router is handling all hash links and tries to convert them into a navigation instruction. Since #! isn’t a valid route, that’s why it was throwing the error.

@janbaer just by trial and error, mostly, lol. I saw that href, then I went to see the router set up in your bootstrap and I saw the HashLocationStrategy. I had problems before because of hashes and HLS, so I gave it a try and it worked.

Glad it worked 👍

@ericmartinezr Thank for your advice! But that you could raise the same error with 4 lines of code doesn’t mean, that I did the same thing in a wrong way and that it’s so easy to reproduce. When it would be so obvious what is wrong I wouldn’t ask here. I know that I don’t use any RxJS functionality in my code in this context. But I know that Angular 2 is doing it, whenever I use an event with @Output. So maybe the error will be occurred from this…

And yes I searched before with a search engine (in my case it was duckduckgo) and I also found this link, but even it was the same error, it was another situation and the solution doesn’t help me.

Of course I know that I can also ask on stackoverflow to try to get help with my problem, but I just thought the best place for problems with using a beta is where the issues that happen with using the beta should be collected and that’s here, since here’re are lot of helpful people away.

But of course you’re right, I should try to make it reproducible or when the effort is too much, post a link to a repo where the error can very easy reproduced.

The repo is here: https://github.com/howcani-project/howcani - you just need to clone it, npm i and gulp

Steps to reproduce:

  1. Click on the headline of one of the cards you see on the right side
  2. Click ok to close the modal dialog.
  3. Now you can see in the console log the errors I posted here.

I’m aware that a plunkr is the fasted way for all here to help and try out to find the problem, but in some cases it’s too much effort to make it reproducible in a plunkr and a lot faster to just try it out in the original source code. And by the way, the problem is also reproducible on the live page on www.howcani.eu (but it runs there only in Safari because of another problem), but the code there is without source map files.