-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
Connection errors are not propagated to the query stream #1847
Comments
I have the same problem here. Obviously nobody is using streaming. But this is far more efficient with larger results. |
@mrx8 I agree, this part of the codebase needs some more attention If you have some capacity any help would be helpful, especially defining an issue ( ideally a failing unit test per issue ) |
@sidorares I've tried to create a failing unit test for my scenario, but it seems my issue is occurring only when I'm running the code in ECMAScript modules (mjs files). Are mjs files supported in mysql2 test runner? |
currently CI matrix includes node 16.x and 18.x so in theory should be ok. I'm not sure if any tweak to path name pattern required, it might be that only *.js files are searched ( we use https://www.npmjs.com/package/urun . I do plan to upgrade to something more modern, probably a built in node test runner ) |
@sidorares Have you already had time to look at the PR from @dsech, which reproduces this issue ? |
Sample code:
If any connection errors occur during the command execution, they will not be caught while iterating over the rows.
After investigation I found the issue to be in
Connection.notifyError
herenode-mysql2/lib/connection.js
Lines 224 to 230 in 88587c6
From what I see, the error will be passed to the command only if the command was executed with a callback.
A solution that seems to fix the issue is to also emit the error to the command like this:
With the above change the error will be emitted to the command, and will also be thrown when iterating over the stream.
Can be reproduced by running a slow query like
SELECT SLEEP(30)
and then issue aKILL "connection id"
The text was updated successfully, but these errors were encountered: