Replies: 0 comments 8 replies
-
What you're describing is the expected behavior, there's no bug. I think you may be confusing From the documentation on
|
Beta Was this translation helpful? Give feedback.
-
I understand what you saying about. But.
|
Beta Was this translation helpful? Give feedback.
-
On my opinion, problem can be, if socket has no 'data' listener, it ignores all packets including FIN packet. Try https://github.com/didkovsky/onend/tree/main/tcp example, with the commented string |
Beta Was this translation helpful? Give feedback.
-
This is expected. The |
Beta Was this translation helpful? Give feedback.
-
But why it's emitted if the "data" listener is attached? If we have .on('data') listener, and we got the 'end' signal, socket will be closed. |
Beta Was this translation helpful? Give feedback.
-
Streams start out in paused mode. Attaching a |
Beta Was this translation helpful? Give feedback.
-
This is a good point. Thank you. If we call const { createServer } = require('net')
createServer(socket => {
// Returns false
console.log(socket.isPaused())
}).listen(444) Also, this is not an answer why we do not receiving the From nodejs doc:
Also from doc:
If we check |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version
v19.2.0
Platform
OSX 12.15.1
Subsystem
No response
What steps will reproduce the bug?
I found few cases when a Socket from node/net isn't closes when it should. Examples:
TCP issue
If a listener .on('data') on a server socket not defined, the 'end' signal from the clients side will be ignored.
Server source
Client source
HTTP issue 1
This issue is a consequence of the TCP issue above. If we have not listener .on('data') on a req object, the 'end' signal from the clients side will be ignored.
Server source
Client source
HTTP issue 2
Server cannot close connection through res.end().
Server source
Clien source
Repo with examples: https://github.com/didkovsky/onend
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
If I call socket.end() I expect to get 'end' event. And stop receiving data on .on('data') listener.
What do you see instead?
If we have not .on('data') listener, socket ignore 'end' signal.
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions