Skip to content

Draining the pool after releasing connections may cause write to destroyed stream #58

@irgijs

Description

@irgijs

Using

pool.release();
pool.drain();

May (not necessarily) result in the error below
Connection lost - Cannot call write after a stream was destroyed

The pool.release methods calls the connection.reset method. This methods executes SQL queries to reset to the initial state of the connection. pool.release does not use promises, so pool.drain in the above example is immediately called afterwards. pool.drain closes the connections. If one of these connections still have a request connection pending (or any other request!) it results in the above mentioned error.

I will provide a PR containing a fix soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions