Search code examples
angularrxjsangular-routingangular7rxjs6

ERROR EmptyErrorImpl {message: "no elements in sequence", name: "EmptyError"} in Angular 7


I am getting a weird error while trying to navigate to different routes from a specific component. If I navigate to different routes from other components I am not seeing this error. I am attaching the screenshot of the error enter image description here

I have searched for this issue and seems to be the problem with RxJS or empty routes. But I added pathMatch:'full' to empty routes and my RxJS version is 6.3.3. Any idea or anyone out here resolved the same issue could be of great help.


Solution

  • EmptyError is thrown by the first pipe if the source observable is closed before it could emit any notification.

    Your stack trace shows that TextblockComponent triggers a takeUntil pipe in its ngOnDestroy function, which usually closes an Observable. It can be assumed that this closes the Observable that has the first pipe and thus causes an EmptyError.

    The error can be circumvented by using take(1) instead of first().