Open
Description
Environment
Windows 11 24H2
Node.js v18.20.5
[email protected]
Reproduction
https://github.com/eltigerchino/crossws-windows-socket-error-repro
Reproduction steps included in the repository README.md
Describe the bug
Returning/throwing a Response that has a body during the upgrade
hook on a Windows machine causes the Node http server to crash.
Additional context
Related function:
Lines 203 to 220 in cad4a65
I experimented a bit and calling socket.destroy()
after the upgrade seems to prevent the crash but I don't think that's the right solution?
I also tried awaiting the socket.write(chunk)
operations by passing it a callback that resolves a Promise but that doesn't solve the issue either (it just ensures writes are all done before socket.end()
)
Logs
node:events:495
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v18.20.5
ELIFECYCLE Command failed with exit code 1.