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

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

Open
irgijs opened this issue Aug 22, 2019 · 3 comments

Comments

@irgijs
Copy link

irgijs commented Aug 22, 2019

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.

@irgijs
Copy link
Author

irgijs commented Aug 22, 2019

Pull Request: #59

@nul
Copy link

nul commented Mar 19, 2020

Is there any update on this?

@irgijs
Copy link
Author

irgijs commented Mar 26, 2020

@nul The PR was an example fix for this problem, it's up to the maintainer of this repo if our example should be used to fix this. (But the example I provided does work, so I suggest to fork this repo and apply the fix yourself using the PR since this repository is not actively maintained anymore)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants