Skip to content

Incorrect execution order allows potential operations on a closed channel #210

Description

@appkit-framework

Hello,

When calling two channel methods one after another, for example exchangeDeclare and queueDeclare, if the first method causes the channel to close (e.g., the exchange is already declared but with a different type), the second method will be executed on the closed channel, causing the connection to be closed as well.

In the case of calls even with a minimal delay, everything works correctly.

This issue arises because Rabbit first resolves the promise that the method, like exchangeDeclare, is awaiting. Then, the method returns, and any further user code (i.e., the call to the next channel method) is executed. Only afterward does Rabbit handle the channel's closure.

The problem persists even after applying all the fixes from my previous pull requests.

I understand that if the first call throws an exception, the user should expect the channel to be closed and avoid further operations on it. However:

  • calls can be executed from different parts of the program, which are unaware of each other
  • on('close') handler may be used to restore the closed channel

If this issue is not addressed in the meantime, I will try to work on a solution in my free time and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions