You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Calling socket.destroy seems logical (will have to confirm later) why do you think is not a right choice?
I think I misunderstood the API. I got the impression that socket.end is preferred over socket.destroy when googling around the other day but I guess that's not the case.
Maybe sendResponse needs to return something like this? (I'm not sure about the call order/sync/async nature of the operations):
Destroy the stream. Optionally emit an 'error' event, and emit a 'close' event (unless emitClose is set to false). After this call, the readable stream will release any internal resources and subsequent calls to push() will be ignored.
By default, stream.end() is called on the destination Writable stream when the source Readable stream emits 'end', so that the destination is no longer writable.
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:
crossws/src/adapters/node.ts
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 beforesocket.end()
)Logs
The text was updated successfully, but these errors were encountered: