search

Home  >  Q&A  >  body text

javascript - An error keeps appearing when using koa mysql2

I used the koa project generated by koa-generator. The routing part is written as follows:

router.get("/test",async (ctx, next) =>{

});

Mysql needs to be used. I chose the promise form of mysql2. Directly refer to the following link:

https://github.com/sidorares/...

But every once in a while, an error will be reported:

events.js:163
      throw er; // Unhandled 'error' event
      ^

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

I am here to ask about the reason for this error and how to solve it in this case. Thank you.

大家讲道理大家讲道理2768 days ago908

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-12 09:22:20

    No caught exceptions. Use

    try ... catch ...

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-12 09:22:20

    Add two ways to manually close the connection after an exception

    connection.end(function(err) {
      // The connection is terminated now
    });
    --------------------
    
    connection.destroy();

    reply
    0
  • Cancelreply