Angular-cli: ng CLI 1.5.5: ERROR Error: Uncaught (in promise): EmptyError: no elements in sequence

Created on 2 Dec 2017  路  17Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 1.5.5
Node: 9.2.0
OS: darwin x64
Angular: 5.0.5

Repro steps

Difficult to reproduce.
I guess this is more a question of how to track the bug.

I have an Angular 5 app, which I upgraded from using the CLI from 1.5.0 to 1.5.4.
In these versions the bug does not happen.

But with CLI 1.5.5 I do see the bug, when started with the CLI or bundled in a Web-Archive (.WAR file) deployed in an OSGi container.

Observed behavior

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)

In Chrome Dev Tools, I pause on caught exceptions.
Still, I have difficulty in idetifying the cause.

Desired behavior

This happens right in the login page.
The page does not change to the first page that is authenticated.
I also commented the guard which is used to secure the routes.
The error still shows up.

Mention any other details that might be useful (optional)

Most helpful comment

The suggested fix of downgrading "rxjs" to "5.5.2" didn't worked for me, but the workaround (adding pathMatch: 'full') suggested by @fabiogodoy resolved my issue.
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'about',
component: AboutComponent,
pathMatch: 'full'
}

All 17 comments

I also faced the same issue.

Versions
Angular CLI: 1.5.5
Node: 8.9.1
OS: linux x64
Angular: 5.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.5
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.38
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.5
@schematics/angular: 0.1.8
typescript: 2.4.2
webpack: 3.8.1

For a fix, look for the comment from @kaaterskil in the issue @ericmartinezr linked above.

The suggested fix of downgrading "rxjs" to "5.5.2" didn't worked for me, but the workaround (adding pathMatch: 'full') suggested by @fabiogodoy resolved my issue.
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'about',
component: AboutComponent,
pathMatch: 'full'
}

@nawnitraman when you downgraded rxjs, did you remove node_modules and re-install? I just changed "^5.5.2" to "5.5.2" and the error went away.

@austinthedeveloper good catch! It worked after re-install. Thanks.

Downgrading from rxjs 5.5.3 to 5.5.2 fixed issue for me.

I love you guys, I had this problem but with CLI 1.3.0 and angular 4.4.6 and this worked, now I can go to sleep!

also have this in newly generated app with 16.0.0.rc1

Following @austinthedeveloper's advise helped.
On the other hand, @nawnitraman's suggestion did not work in my case.

Thanks for the quick responses!

Based on the responses, I am going to close this issue.
There are many suggestions, direct or referred to, that work.

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)

Can i have solution for this?

you need add a null component. and add redirect route, like this:
{ path: '', redirectTo: '/yourNullComponent', pathMatch: 'full' }

I have a component with path:'',, i can't change that component.

I faced the same issue apply, all possible solution but finally, this solve my problem

export class AppRoutingModule {
constructor(private router: Router) {
    this.router.errorHandler = (error: any) => {
        this.router.navigate(['404']); // or redirect to default route
    }
  }
}

Hope this will help you.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hareeshav picture hareeshav  路  3Comments

sysmat picture sysmat  路  3Comments

naveedahmed1 picture naveedahmed1  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

rwillmer picture rwillmer  路  3Comments