Closed
Description
Version
v18.15.0
Platform
Win 8.1 x64
Subsystem
net
What steps will reproduce the bug?
'use strict';
const net = require('net');
const stream = require('stream');
function check(stm)
{
stm.on('finish', () => console.log('finish'));
stm.on('close', () => console.log('close'));
stm.end(() => console.log('ended'));
}
// nothing is printed
check(new net.Socket());
// 'finish' and 'ended' is printed
// check(new stream.Writable());
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Expect at least 'ended' to show
What do you see instead?
nothing printed
Additional information
All streams seem to always call the callback from end()
but non-connected sockets do not thus violating stream.Writable
API.
Why it is needed: I use universal function to close stream gracefully and when it's done call destroy
. With this behavior the function stucks at non-connected sockets. Currently I seem to have to check stream.writable
and only call end
when it's true.
Activity