Rxjs: 5.5.3 EmptyError: no elements in sequence

Created on 2 Dec 2017  路  30Comments  路  Source: ReactiveX/rxjs

RxJS version:
5.5.3

Code to reproduce:
since my update to 5.5.3 i'm getting errors in otherwise perfectly fine running angular 5.x application

this is the error i'm getting this morning

all was working perfectly prior to 5.5.3

difficult for me to trap what the reason could be thanks

Error: Uncaught (in promise): EmptyError: no elements in sequence
EmptyError: no elements in sequence
    at new EmptyError (EmptyError.js:27)
    at FirstSubscriber._complete (first.js:154)
    at FirstSubscriber.Subscriber.complete (Subscriber.js:121)
    at MergeMapSubscriber._complete (mergeMap.js:144)
    at MergeMapSubscriber.Subscriber.complete (Subscriber.js:121)
    at MapSubscriber.Subscriber._complete (Subscriber.js:139)
    at MapSubscriber.Subscriber.complete (Subscriber.js:121)
    at EmptyObservable._subscribe (EmptyObservable.js:82)
    at EmptyObservable.Observable._trySubscribe (Observable.js:173)
    at EmptyObservable.Observable.subscribe (Observable.js:161)
    at new EmptyError (EmptyError.js:27)
    at FirstSubscriber._complete (first.js:154)
    at FirstSubscriber.Subscriber.complete (Subscriber.js:121)
    at MergeMapSubscriber._complete (mergeMap.js:144)
    at MergeMapSubscriber.Subscriber.complete (Subscriber.js:121)
    at MapSubscriber.Subscriber._complete (Subscriber.js:139)
    at MapSubscriber.Subscriber.complete (Subscriber.js:121)
    at EmptyObservable._subscribe (EmptyObservable.js:82)
    at EmptyObservable.Observable._trySubscribe (Observable.js:173)
    at EmptyObservable.Observable.subscribe (Observable.js:161)
    at AppErrorHandler.handleError (app.exception.ts:47)
    at Object.next (core.js:5377)
    at SafeSubscriber.schedulerFn [as _next] (core.js:4223)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:246)
    at SafeSubscriber.next (Subscriber.js:193)
    at Subscriber._next (Subscriber.js:132)
    at Subscriber.next (Subscriber.js:96)
    at EventEmitter.Subject.next (Subject.js:63)
    at EventEmitter.emit (core.js:4203)
    at core.js:4652

Most helpful comment

This can help (using rxjs 5.5.3 - "rxjs": "^5.5.2")

Bug with empty path:

const routes: Routes = [
{ path: "", component: SynthesisComponent },
{ path: "home", component: SynthesisComponent },
{ path: "about", component: AboutComponent },
...
];

Ok when using pathMatch: 'full':

const routes: Routes = [
{ pathMatch: 'full', path: "", component: SynthesisComponent },
{ pathMatch: 'full', path: "home", component: SynthesisComponent },
{ pathMatch: 'full', path: "about", component: AboutComponent },
...
];

From https://github.com/angular/angular-cli/issues/8724 (nawnitraman)

All 30 comments

After an update of my angular project I get the same error. In my case, routing with children and outlets doesn't work.

Experiencing the same thing. Had to fix rxjs version in package.json to prevent CI from installing version 5.5.3: "rxjs": "5.5.2"

HI,

I've the same error.

Me too with an Angular 5.0.5 project. After downgrading rxjs to 5.5.2 the problem went away.

See Angular issue #20752 for a minimal reproduction of the problem.

@Cito that solved!

FYI: In react project, v5.5.3 upgrade also breaking app. In this case import Rx from 'rxjs/Rx' is returning undefined; producing TypeError: Cannot read property 'Subject' of undefined. This was functioning fine prior to to this minor release.

I'll try to look into this shortly.

  • I noticed a small regression in bundle size ~10kb when upgrade from 5.5.2 -> 5.5.3

This is breaking prettier/prettier-eslint-cli as we're doing import Rx from "rxjs/Rx"; which is now returning undefined so we can't access Rx.Observable.....

Update:
I've updated the way we import rxjs in the package so this isn't a problem for us any longer.

Edit: I've must have put this in the wrong issue 馃槙

We have added quick fix for this and patch will be released soon.

I got the error also with 5.5.3 , does it already work ?

This can help (using rxjs 5.5.3 - "rxjs": "^5.5.2")

Bug with empty path:

const routes: Routes = [
{ path: "", component: SynthesisComponent },
{ path: "home", component: SynthesisComponent },
{ path: "about", component: AboutComponent },
...
];

Ok when using pathMatch: 'full':

const routes: Routes = [
{ pathMatch: 'full', path: "", component: SynthesisComponent },
{ pathMatch: 'full', path: "home", component: SynthesisComponent },
{ pathMatch: 'full', path: "about", component: AboutComponent },
...
];

From https://github.com/angular/angular-cli/issues/8724 (nawnitraman)

Is this a temporary solution or a standard solution? Are you going to release a bug fix?

Fixed this issue in my setup by changing rxjs from ^5.4.2 to 5.5.2.

quick fix tested in 2 projects - in package.json replace "rxjs": "^5.5.2" or "rxjs": "^5.5.3" with "rxjs": "5.5.2"

ERROR Error: Uncaught (in promise): EmptyError: no elements in sequence
EmptyError: no elements in sequence
at new EmptyError (EmptyError.js:28)
at FirstSubscriber._complete (first.js:154)
at FirstSubscriber.Subscriber.complete (Subscriber.js:122)
at MergeMapSubscriber._complete (mergeMap.js:150)
at MergeMapSubscriber.Subscriber.complete (Subscriber.js:122)
at MapSubscriber.Subscriber._complete (Subscriber.js:140)
at MapSubscriber.Subscriber.complete (Subscriber.js:122)
at EmptyObservable._subscribe (EmptyObservable.js:83)
at EmptyObservable.Observable._trySubscribe (Observable.js:172)
at EmptyObservable.Observable.subscribe (Observable.js:160)
at new EmptyError (EmptyError.js:28)
at FirstSubscriber._complete (first.js:154)
at FirstSubscriber.Subscriber.complete (Subscriber.js:122)
at MergeMapSubscriber._complete (mergeMap.js:150)
at MergeMapSubscriber.Subscriber.complete (Subscriber.js:122)
at MapSubscriber.Subscriber._complete (Subscriber.js:140)
at MapSubscriber.Subscriber.complete (Subscriber.js:122)
at EmptyObservable._subscribe (EmptyObservable.js:83)
at EmptyObservable.Observable._trySubscribe (Observable.js:172)
at EmptyObservable.Observable.subscribe (Observable.js:160)
at resolvePromise (zone.js:824)
at resolvePromise (zone.js:795)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4621)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at drainMicroTaskQueue (zone.js:602)
at ZoneTask.invokeTask [as invoke] (zone.js:503)
at invokeTask (zone.js:1540)

I want solve this problem with RxJS5.5.3 only, is there any solution for that?

I am getting the same error when I press an anchor element, and the anchor element is using [routerLink]="'somePath'". I do not know if this is limited to anchor tags or not. I am using rxjs:5.2.2, as suggested by some others, but I am still receiving errors. (Adding pathMatch:'full' to the routes in the router module as sugested by @dhabierre works though).

I have had the same problem. It was because I was using a modal from ng2-bootstrap-modal.
import { BootstrapModalModule } from 'ng2-bootstrap-modal';
If this is your case. Try use forRoot and pathMatch:'full' to the routes in the router module

imports: [..., ModalModule.forRoot(), ..]

Please try [email protected] it fixed my issues

5.5.4 works

I'm still getting the same issue. I downgraded to 5.5.2 and also tried 5.5.4...both are not working for me.

update to 5.5.5 is ok.

Tried 5.5.5 as you suggested- still getting the same error...

@mmanavaz make sure to remove your node_modules and reinstall the dependencies after you changed the versions. If that does not help, try clearing your npm cache.

I was able to get it working, thank you @beeman

I just resolved it by removing its cap (^) from "rxjs": "^5.5.2", to "rxjs": "5.5.2",

I got this error in an angular app, and wanted to explain how I fixed it, in-case anyone runes into it in the future, as it doesn't seem like the most common error, and the error displayed in the console isn't very helpful at all.
I got this issue when refreshing the page on a page that uses a guard.
I found this pattern being used in my code:

// in some service used to "cache" roles
this.roles: Observable<Array<Role>>;
if (!this.roles) {
  this.roles = this.rolesService.getRoles().share(); // Using this share broke the request
}
return this.roles;

// in some guard, which crashes when getting the values
return this.rolesCache.map(roles => roles.length > 1);

I guess "caching" whatever the share() ends up throwing this error when I try to get the values later.

I am still having this issue - on "version": "5.5.6" of rxjs and Angular 5.2.10. I have also tried the pathMatch: 'full' as well and it still does not work...

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Agraphie picture Agraphie  路  3Comments

benlesh picture benlesh  路  3Comments

marcusradell picture marcusradell  路  4Comments

Zzzen picture Zzzen  路  3Comments

dooreelko picture dooreelko  路  3Comments