-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: fix memory leak when socket dns lookup occurs error (#348)
- Loading branch information
Showing
4 changed files
with
21 additions
and
9 deletions.
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
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
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,19 @@ | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
var common = require('../common'); | ||
|
||
var host = 'www.unable-to-resolved-host.rokid.com'; | ||
var req = http.request({ host: host }); | ||
|
||
req.socket.on('finish', common.mustCall(() => { | ||
process.nextTick(() => { | ||
var destroyed = req.socket._socketState.destroyed; | ||
console.log(`socket is destroyed ${host}:`, destroyed); | ||
assert.equal(destroyed, true); | ||
}); | ||
})); | ||
|
||
// handle error event to prevent the process throw an error | ||
req.on('error', common.mustCall((err) => { | ||
console.log('request error', err.message); | ||
})); |
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