-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
- Loading branch information
Showing
2 changed files
with
31 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
const uv = process.binding('uv'); | ||
|
||
const s = new net.Socket({ | ||
handle: { | ||
readStart: function() { | ||
process.nextTick(() => this.onread(uv.UV_EOF, null)); | ||
}, | ||
close: (cb) => process.nextTick(cb) | ||
}, | ||
writable: false | ||
}); | ||
s.resume(); | ||
|
||
const events = []; | ||
|
||
s.on('end', () => events.push('end')); | ||
s.on('close', () => events.push('close')); | ||
|
||
process.on('exit', () => { | ||
assert.deepStrictEqual(events, [ 'end', 'close' ]); | ||
}); |