Skip to content

NavigationError EmptyError: no elements in sequence since upgrade to 14.1 #47089

@jogelin

Description

@jogelin

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

Hello,

Since the upgrade from Angular 14.0.6 to 14.1.1, all of your routing configurations are broken because rxjs is throwing an EmptyError when processing the routing.

After some searching, I found that it is related to the commit 72e6a94 from @atscott

It seems that the observable processSegment is closed before emitting a value:

 processSegment(injector, routes, segmentGroup, segments, outlet) {
        return from(routes).pipe(concatMap(r => {
            return this.processSegmentAgainstRoute(r._injector ?? injector, r, segmentGroup, segments, outlet);
        }), first((x) => !!x), catchError(e => {
            // THE ERROR IS THROWN HERE
            if (e instanceof EmptyError) {
                if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
                    return of([]);
                }
                return of(null);
            }
            throw e;
        }));
    }

I suspect the first operator above.

My routing configuration:

{
    path: ':brandId',
    children: [
      { path: '', redirectTo: 'admin', pathMatch: 'full' },
      {
        path: 'admin',
        children: [
          {
            path: '',
            redirectTo: 'orga',
            pathMatch: 'full',
          },
          {
            path: 'orga',
            component: OrganizationComponent,
            children: [
              {
                path: 'test',
                component: DetailsComponent,
              },
            ],
          },
        ],
      },
    ],
  },

WHen I remove the last config:

            children: [
              {
                path: 'test',
                component: DetailsComponent,
              },
            ],

It works !!

Any ideas?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.1.1
Node: 16.15.0
Package Manager: yarn 1.22.15
OS: darwin x64

Angular: 14.1.1
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1401.1
@angular-devkit/build-angular   14.1.1
@angular-devkit/core            14.1.1
@angular-devkit/schematics      14.1.1
@schematics/angular             14.1.1
rxjs                            7.5.6
typescript                      4.7.4
webpack                         5.73.0


the project is also using Nrwl/Nx:
   Node : 16.15.0
   OS   : darwin x64
   yarn : 1.22.15

   nx : 14.5.4
   @nrwl/angular : 14.5.4
   @nrwl/cypress : 14.5.4
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.5.4
   @nrwl/eslint-plugin-nx : 14.5.4
   @nrwl/express : Not Found
   @nrwl/jest : 14.5.4
   @nrwl/js : 14.5.4
   @nrwl/linter : 14.5.4
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.5.4
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 14.5.4
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.5.4
   @nrwl/web : 14.5.4
   @nrwl/workspace : 14.5.4
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
   	 @auth0/auth0-angular: 1.10.0
   	 @cumul.io/ngx-cumulio-dashboard: 3.0.2
   	 @ngneat/edit-in-place: 1.6.1
   	 @ngneat/transloco: 4.1.1
   	 @ngrx/component: 14.0.2
   	 @ngrx/component-store: 14.0.2
   	 ng2-charts: 3.0.11
   	 single-spa-angular: 7.1.0
   	 @compodoc/compodoc: 1.1.19
   	 @ngneat/spectator: 11.1.0
   	 @storybook/angular: 6.5.9
   	 @twittwer/compodoc: 1.8.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfularea: routerregressionIndicates than the issue relates to something that worked in a previous version

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions