Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser endless loop and crash on @Effect #17

Open
felixunivers opened this issue Apr 29, 2019 · 0 comments
Open

Browser endless loop and crash on @Effect #17

felixunivers opened this issue Apr 29, 2019 · 0 comments

Comments

@felixunivers
Copy link

felixunivers commented Apr 29, 2019

If by accident I placed the same Action (.Load in my case) in my Effect in the ofType filter and then in the map of my service result Observable and run the project, my browser gets into endless loop with fast increasing number of errors. The systems stalls, browser must be killed to terminate the trouble.

If I fix the error and replace: .Load with the intended: .Loaded, all is fine. The code runs.

The issue is in the bug handling of the erroneous entry.
I am assuming this is an unexpected behavior and should be addressed with revised bug handling.

Here is my Effect example. (Let me know if you need other pieces of the code).


@Injectable()
export class FetchMenuDataEffects {

  constructor(private actions$: Actions<Menu01Actions>,
              private menuDataService: MenuDataService) {}

  @Effect()
  loadMenuItems$ = this.actions$
    .pipe(
      ofType(Menu01ActionTypes.Load),                                   // <<< same action: .Load
      mergeMap(() => this.menuDataService.getMenuItemsFromLocalDataSource()
        .pipe(
          map(menuItems =>
// (tested: menuItems  returns accurate result from the service above)
// >>> here is the error:   .Load  ( - should be:  .Loaded )
                ({ type: Menu01ActionTypes.Load, payload: menuItems })  // <<< same action: .Load
             ),
          catchError(() => EMPTY)
        ))
      );
}
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant