fix: reconstruct corrupted server.js message pipeline - #218
Open
ayomidemariam wants to merge 1 commit into
Open
Conversation
- Remove duplicate wss and httpServer declarations causing SyntaxError
- Merge two scrambled implementations into single coherent createServer
- Add /health and /healthz endpoints returning JSON responses
- Add /readyz readiness endpoint with connection/room counts
- Add /metrics Prometheus endpoint tracking connections, messages, auth
- Add markShuttingDown() for graceful shutdown support
- Restore safeSend wrapper for error-safe WebSocket sends
- Restore per-message rate limiting via createRateLimiter import
- Fix clearInterval referencing undefined 'interval' variable
- Add per-IP connection count tracking with configurable max
- Return { wss, httpServer, rooms, markShuttingDown }
- All 178 tests pass, lint clean
Closes RiftCore00#191
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reconstructs the fatally corrupted
src/server.jswhich had duplicatewssdeclarations causingSyntaxError: Identifier 'wss' has already been declared, preventing 6 test suites from loading.Root Cause
The upstream
server.jscontained two interleaved implementations merged incorrectly:const wss = new WebSocketServer(...)on line 31 bound toserverconst wss = new WebSocketServer({ noServer: true })on line 53serverandhttpServer)clearInterval(interval)referencing undefined variable (should beheartbeatInterval)createRateLimiterimport andsafeSendfunctionChanges
const wssbound tohttpServer/health(returns{ status: "OK" }) and/healthz(returns{ status: "ok", uptime }) for backward compatibility/readyzreadiness endpoint with connection/room counts/metricsPrometheus-format endpoint tracking connections, messages, auth failures, heap usagemarkShuttingDown()method for graceful shutdown (503 responses)safeSendwrapper for error-safe WebSocket sendscreateRateLimiterimportclearIntervalreferencing correctheartbeatIntervalvariablemaxConnectionsPerIp{ wss, httpServer, rooms, markShuttingDown }supporting bothwss.address()andhttpServer.address()patternsVerification
Closes #191