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

Interceptors no longer work with RxJS retry operator #11923

Closed
2 tasks done
geersch opened this issue Jun 28, 2023 · 5 comments · Fixed by #11926
Closed
2 tasks done

Interceptors no longer work with RxJS retry operator #11923

geersch opened this issue Jun 28, 2023 · 5 comments · Fixed by #11926
Labels
needs triage This issue has not been looked into type: bug 😭

Comments

@geersch
Copy link

geersch commented Jun 28, 2023

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

PR #11142

NestJS version

9.4.2 -> 10.0.3

Describe the regression

I maintain 2 packages @geersch/retry and @geersch/nestjs-retry. The former one offers a retry function supporting exponential backoff (powered by RxJS) and the latter allows you to use it via a NestJS interceptor.

@Controller('cats')
class CatsController {
  @Get()
  @UseInterceptors(new RetryInterceptor(FixedBackoffStrategy))
  findAll(@Headers('x-attempt') header: number): string {
    return 'all the cats';
  }
}

This worked fine with NestJS 9.x.x, but with NestJS 10 it breaks and the tests of @geersch/nestjs-retry package fail. The retry operator which is eventually piped into the next.handle() observable does retry X times, but it appears that the actual controller method is not invoked more than once anymore, breaking the retry mechanism.

Minimum reproduction code

geersch/retry#5

Input code

I made PR where I update the dependencies to NestJS 10.0.3.

geersch/retry#5

The automated tests (Github actions) fail for the @geersch/nestjs-retry package. See retry-interceptor.spec.ts for the failing tests. It's just a simple controller with a few controller methods and 4 tests which all fail.

You can reproduce this by cloning this repository, switching to the fix/nestjs10 branch and running the tests.

git clone git@github.com:geersch/retry.git
git checkout fix/nestjs10
yarn

Be sure to the build script (yarn build) from the root first before running the tests.

yarn workspace @geersch/nestjs-retry test --watch

Expected behavior

I would expect the controller method to be retried when I pipe this into the RxJS retry operator.

Other

No response

@geersch geersch added needs triage This issue has not been looked into type: bug 😭 labels Jun 28, 2023
@shavidze
Copy link

shavidze commented Jun 28, 2023

Yes, I think this PR caused this issue. I'm not 100 sure but the potential reason is that the handle method of the handler object is still calling nextFn(i + 1), but now it's not wrapped in a function.

@micalevisk
Copy link
Member

hi @nordfjord do you mind on helping us to investigate this issue? thanks in advance.

@nordfjord
Copy link
Contributor

I would suggest reverting that PR if it's causing issues with something as important as retries 😬

@nordfjord
Copy link
Contributor

I believe I have a fix in #11926

@kamilmysliwiec
Copy link
Member

Let's track this here #11926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: bug 😭
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants