question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throw an error when a connection ends with a RST,ACK packet?

See original GitHub issue

Hi,

I’m using Azure MySQL database.

According to MySQL docs, COM_QUIT command should end with “either a connection close or a OK_Packet”.

It can be reproduced when you run this example code against an Azure MySQL instance.

var mysql      = require('mysql2');
var connection = mysql.createConnection({ config });

connection.connect();

connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
  if (error) throw error;
  console.log('The solution is: ', results[0].solution);
});

connection.end();

Throws ECONNRESET error.

Should this library throw an error when a connection end with a RST with the ACK flag set? Can we detect this?

I see mysqljs already fixed it at commit https://github.com/mysqljs/mysql/commit/9168ced54148721c8872ddab583116f00b4bc4f8 . But we prefer using mysql2 now and it block me. Could mysql2 fix it either?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sidorarescommented, Apr 11, 2018

probably fix should be here - https://github.com/sidorares/node-mysql2/blob/5c5aa3aed7e772e599dbefdafb04405672901808/lib/connection.js#L123

if already _closing, ignore error ( same way .end() is expected when this flag set on line 94 )

0reactions
elemountcommented, Apr 12, 2018

I used the code in the _handleNetworkError and now it works. I raised a pull request on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Throw an error when a connection ends with a RST,ACK ...
According to MySQL docs, COM_QUIT command should end with "either a connection close or a OK_Packet". As @elemount pointed out in issue ...
Read more >
Raise exception when TCP connection broken - Stack Overflow
Being at end of file is not intrinsically an error, nor is it normally understood to mean a "broken" connection like your title...
Read more >
end{align} throws Package inputenc Error - TeX
Does somebody know why I get this error and how to fix it? There isn't even a "-" in the line "\end{align}"? Also,...
Read more >
Error handling in R with tryCatchLog: Catching, logging, post ...
The call stack ends basically with the tryCatch call but does not show you the code line in f() where the error was...
Read more >
Errors | Node.js v19.3.0 Documentation
It is used when catching an error and throwing a new one with a different message or code in order to still have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found