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

Unexpected channel closed error while processing an incoming message #159

Closed
derevnjuk opened this issue Jun 19, 2023 · 0 comments · Fixed by #161 · May be fixed by trailblazing-dx/zolamk-brokencrystals#128
Closed

Unexpected channel closed error while processing an incoming message #159

derevnjuk opened this issue Jun 19, 2023 · 0 comments · Fixed by #161 · May be fixed by trailblazing-dx/zolamk-brokencrystals#128
Assignees
Labels
Type: bug Something isn't working

Comments

@derevnjuk
Copy link
Member

An unexpected error occurs when processing an incoming message, leading to a "channel closed" error. This issue is likely caused by unhandled errors during the message processing. To prevent this error from crashing the application, we should implement error handling to gracefully handle any errors that may occur.

Expected Behavior
When an error occurs during the processing of an incoming message, the application should handle the error gracefully and log the error message without crashing.

Actual Behavior
Currently, the application crashes with an "Channel closed" error when an error occurs during the processing of an incoming message.

Proposed sollution

private async startBasicConsume(channel: Channel): Promise<void> {
  await channel.consume(
    this.options.clientQueue,
    async (msg: ConsumeMessage | null) => {
      try {
        if (msg) {
          await this.processMessage(msg);
        }
      } catch (e) {
        this.logger.error(
          'Error while processing a message due to an error occurred: ',
          e
        );
      }
    },
    {
      noAck: true
    }
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working
Projects
None yet
1 participant