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.

I get these errors sometimes. Randomly.

    Error: read ECONNRESET 
        at exports._errnoException (util.js:742:11) 
        at TCP.onread (net.js:535:26)

and

    Error: write ECONNRESET 
        at exports._errnoException (util.js:742:11) 
        at Object.afterWrite (net.js:749:14) 

I read somewhere that this also happens on node-mysql, but that it could be fixed by using pool. I began using pool, but it still happens.

Suggestions?

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
farzhercommented, Jan 14, 2019

for anyone getting this error randomly. i guess you’re supposed to write this wrapper around pool.query (or whatever call you’re using). stops the problem for me.

function query_with_retries(sql, params, retries_left=1) {
  try {
    return pool.query(sql, params)
  } catch(err) {
    if(retries_left >= 1 && err.code === 'ECONNRESET') {
      console.error({msg:'query_with_retries retrying!', retries_left, err})
      return query_with_retries(sql, params, retries_left-1)
    } else {
      throw err
    }
  }
}
1reaction
jsbinettecommented, Jan 10, 2019

For one I agree that this driver should have a ‘keep alive’ option.  It’s hard to debug and there are no ‘using’ keyword like c# that makes it easy o handle in JavaScript

Thursday, January 10, 2019, 6:42 PM -0500 from notifications@github.com notifications@github.com:

@farzher this is a low level driver and retries out of the scope. It’s not clear from your report if you can catch and process error in your code or it’s something that your code can’t handle ( if latter, it definitely need to be fixed ) The “best practise” usually is to never use individual connections directly and use connection pool ( even if one connection is enough from perf point of view ). But even with pool you absolutely must be able to handle errors from production code and make a decision what to do ( retry / log / report to user ) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I debug error ECONNRESET in Node.js?
ECONNRESET occurs when the server side closes the TCP connection and your request to the server is not fulfilled. The server ...
Read more >
What does “Error: read ECONNRESET” mean? - Quora
You might have guessed it already: it's a connection error. "ECONNRESET" means the other side of the TCP conversation abruptly closed its end...
Read more >
Fixing an ECONNRESET error - Postman
The ECONRESET error means that the server unexpectedly closed the connection and the request to the server was not fulfilled. Connection-related ...
Read more >
How do I debug error ECONNRESET in Node.js?
“ECONNRESET” means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one...
Read more >
Return code ECONNRESET for TCP/IP - IBM
Depending upon the platform or platforms your enterprise uses, you receive the following return code when the connection is reset by peer (ECONNRESET):....
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