-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Failed retries do not work in kafka. #4241
Comments
He found a solution that might or may not be the definitive solution. @UseFilters must be implemented inside the ExceptionFilter an error must be generated so that the error flow follows the same flow as with kafkajs example ExceptionFilter:
How to implement it in each consumer:
|
Hi, Im dealing with the same issue and your solution actually doesnt work for me |
We are facing the same issue and as well the solution outlined by @LaThortilla didn't work for us. Tried following Filter: import { ArgumentsHost, Catch } from '@nestjs/common';
import { BaseRpcExceptionFilter } from '@nestjs/microservices';
import { Observable, throwError } from 'rxjs';
@Catch()
export class ThrowExceptionFilter implements BaseRpcExceptionFilter {
handleUnknownError(exception: any, status: string): Observable<never> {
throw new Error('Method not implemented.');
}
isError(exception: any): exception is Error {
throw new Error('Method not implemented.');
}
catch(exception: any, host: ArgumentsHost): Observable<any> {
console.log('Catched exception');
console.dir(exception, { depth: null });
throw new Error('Test Error');
// return throwError(() => new Error('test Error'));
}
} Log:
Without the custom filter the RpcExceptionsHandler is catching the exception:
We are using the event-based approach for our Kafka consumers https://docs.nestjs.com/microservices/basics#event. I will try to make a reproduction repo in the next few days. |
Hi. The main problem in Nest's standard event handling. For observable it's creating connectable, which does not throw an error in the context of the
|
Related to #9293 |
I use the latest version now and have the same error |
Bug Report
Current behavior
when an exception is generated in the consumption of an event, retries are not performed in the way that kafkajs does.
Input Code
Message Controller ./src/user.api.controller.ts
./main.ts
Output:
run only one attempt
Expected behavior
You must execute the configured attempts and then fail.
By executing this code using kafkajs easily you get the expected behavior:
index.js
output:
Attempts are shown in the output and then the message received.
Possible Solution
do not intercept the error that is generated within the function and return it to eachMessage
Environment
The text was updated successfully, but these errors were encountered: