Skip to content

Commit fbd92ed

Browse files
author
Rachel Nehmer
committed
Test that we ignore ECONNRESET if connection already closing
1 parent 8cf8d24 commit fbd92ed

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const common = require('../../common')
5+
6+
const error = new Error('read ECONNRESET');
7+
error.code = 'ECONNRESET'
8+
error.errno = -54
9+
error.syscall = 'read';
10+
11+
const connection = common.createConnection();
12+
13+
// Test that we ignore a ECONNRESET error if the connection
14+
// is already closing, we close and then emit the error
15+
connection.query(`select 1`, (err, rows) => {
16+
assert.equal(rows[0]['1'], 1);
17+
connection.close();
18+
connection.stream.emit('error', error);
19+
});
20+
21+
process.on('uncaughtException', err => {
22+
assert.notEqual(err.code, 'ECONNRESET')
23+
});

0 commit comments

Comments
 (0)