forked from sidorares/node-mysql2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that we ignore ECONNRESET if connection already closing
- Loading branch information
Rachel Nehmer
committed
Oct 29, 2021
1 parent
8cf8d24
commit fbd92ed
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
test/integration/connection/test-connection-reset-while-closing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}); |