mirror of https://github.com/lukechilds/node.git
Browse Source
`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: https://github.com/nodejs/node/pull/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>v6.x
committed by
Myles Borins
2 changed files with 31 additions and 3 deletions
@ -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' ]); |
|||
}); |
Loading…
Reference in new issue