debug: delay websocket close and detail auth error

This commit is contained in:
Hamza-Ayed
2026-05-29 01:27:20 +03:00
parent 87ec54bbd7
commit 83f8d6ab65
2 changed files with 14 additions and 12 deletions

View File

@@ -30,10 +30,12 @@ export function setupWebSocket(server, hub, limiter) {
// Hand over control to 'ws' library to complete the upgrade protocol handshake.
wss.handleUpgrade(request, socket, head, (wsConn) => {
// Set remote address on socket mock for later client IP queries.
// This ensures we can resolve client IP even after connection is upgraded.
wsConn._socket = wsConn._socket || {};
wsConn._socket.remoteAddress = ip;
if (wsConn._socket) {
Object.defineProperty(wsConn._socket, 'remoteAddress', {
value: ip,
configurable: true
});
}
// Instantiate a new Client wrapper.
// Event listeners are automatically attached in the Client constructor.