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

mssql errors crash the server instead of bubbling up via pool.promises.query #227

Open
waterfoul opened this issue Jan 18, 2022 · 2 comments

Comments

@waterfoul
Copy link

waterfoul commented Jan 18, 2022

If you are using a connection pool with node 16 using pool.promises.query will cause the server to crash due to an unhandled error. It looks like this is caused by the promise error handler not satisfying the pool's event emitter. If you add pool.on("error", () => {}) it solves the issue. This works as a workaround but should be unnecessary

As a side note promises get rejected with an array, not an Error, on reader.js line 148 this results in a warning when replacing native promises with bluebird. See the bluebird docs for more details. This is non critical but is a code smell nonetheless. It could be easily handled using a custom error object

@TimelordUK
Copy link
Owner

Thanks very much for information. What do you suggest is cleanest fix

@waterfoul
Copy link
Author

I'm not sure how to accomplish it via the layers of your library but Ideally it would just bubble all errors without the unhandled rejection when accessing the pool through pool.promises since the promise api is designed to bubble errors in that way. The trick would be to accomplish this without effecting the non-promise api. Unfortunately the pool.on("error", () => {}) trick just swallows those errors without any error reporting. It works for us since we only access via the promise api

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