-
-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1438 from kneemer/master
Update how the ECONNRESET error is caught when connection already closing
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
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
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') | ||
}); |