mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
31196eaa93
`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>
27 lines
536 B
JavaScript
27 lines
536 B
JavaScript
'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' ]);
|
|
});
|