Skip to content

Commit

Permalink
Test that we ignore ECONNRESET if connection already closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Nehmer committed Oct 29, 2021
1 parent 8cf8d24 commit fbd92ed
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/integration/connection/test-connection-reset-while-closing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const assert = require('assert');
const common = require('../../common')

const error = new Error('read ECONNRESET');
error.code = 'ECONNRESET'
error.errno = -54
error.syscall = 'read';

const connection = common.createConnection();

// Test that we ignore a ECONNRESET error if the connection
// is already closing, we close and then emit the error
connection.query(`select 1`, (err, rows) => {
assert.equal(rows[0]['1'], 1);
connection.close();
connection.stream.emit('error', error);
});

process.on('uncaughtException', err => {
assert.notEqual(err.code, 'ECONNRESET')
});

0 comments on commit fbd92ed

Please sign in to comment.