Open
Description
Version
22.14.0 and probably previous versions
Platform
Linux bjohansebas 6.14.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 10 Apr 2025 18:43:59 +0000 x86_64 GNU/Linux
Subsystem
http, stream
What steps will reproduce the bug?
When using finished, res.writableEnded, or res.writableFinished, it never becomes true
const http = require('http')
const net = require('net')
const finished = require('stream').finished
const assert = require('assert')
var server = http.createServer(function (req, res) {
finished(res, function (err) {
assert.ok(err)
assert.ok(res.writableFinished)
assert.ok(res.writableEnded)
server.close(function () {})
})
socket.on('error', function () {})
socket.write('W')
})
let socket
server.listen(function () {
socket = net.connect(this.address().port, function () {
writeRequest(this, true)
})
})
function writeRequest (socket, chunked) {
socket.write('GET / HTTP/1.1\r\n')
socket.write('Host: localhost\r\n')
socket.write('Connection: keep-alive\r\n')
if (chunked) {
socket.write('Transfer-Encoding: chunked\r\n')
}
socket.write('\r\n')
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
should return true
What do you see instead?
false
Additional information
This is part of the tests for on-finished (https://github.com/jshttp/on-finished/blob/f8b5f4097d28df79e466d1ffdf58ccb27d769156/test/test.js#L368-L387)
I might be using the wrong properties to determine when the request has finished, so i understand this might not be a bug