ngneat / effects

🪄 A framework-agnostic RxJS effects implementation
https://www.netbasal.com
MIT License
63 stars 11 forks source link

After upgrading angular from v13 to v15 I have a problem with catching errors in tapResult's error callback. #49

Open alexeek opened 1 year ago

alexeek commented 1 year ago

Which @ngneat/effects-* package(s) are the source of the bug?

effects-ng

Is this a regression?

Yes

Description

I have angular upgraded from 13 to 15. I am using effects-ng for http requests. In case I have http error I can't get the error response in tapResult's error callback and can't intercept this error inside angular error interceptor. Is there a problem with compatibility or something else? For example I'm getting error 404 from server but code in tapResult's error callback doesn't invokes. And the most important problem is that I can't intercept this error. In previous version of angular (v13) everything worked fine.

  fetch$ = createEffect(actions =>
    actions.pipe(
      ofType(fetchModel),
      switchMap(({ payload }) => {
        return this.modelApiService.fetch(payload).pipe(
          tapResult(
            response => {
              this.modelRepo.addModelAndSetActive(<EntityTypeObjects.ModelEntityObject>response.data);
            },
            (error: string) => {
              //!!!can't get here!!!
              throwError(() => new Error(error));
            }
          )
        );
      })
    )
  );

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

I can't get into error callback in tapResult

Please provide the environment you discovered this bug in

Dependencies

    "@angular/animations": "^15.1.5",
    "@angular/cdk": "^15.1.5",
    "@angular/common": "^15.1.5",
    "@angular/compiler": "^15.1.5",
    "@angular/core": "^15.1.5",
    "@angular/forms": "^15.1.5",
    "@angular/platform-browser": "^15.1.5",
    "@angular/platform-browser-dynamic": "^15.1.5",
    "@angular/router": "^15.1.5",
    "rxjs": "~7.5.0",
...
    "@ngneat/effects": "^1.1.1",
    "@ngneat/effects-ng": "3.1.0",
    "@ngneat/elf": "^2.1.0",
    "@ngneat/elf-cli-ng": "^1.0.0",
    "@ngneat/elf-entities": "^4.3.1",
    "@ngneat/elf-pagination": "^1.0.1",
    "@ngneat/elf-persist-state": "^1.1.2",


### Anything else?

_No response_

### Do you want to create a pull request?

No
EricPoul commented 1 year ago

I've just played with it and it seems fine. Could you provide more info? https://stackblitz.com/edit/angular-ch2mt3?file=src%2Fmain.ts

tapResult hasn't been changed in the last merged features.