▸case-01 Write a TypeScript module for a Node.js real-time backend that creates an HTTP server and attaches a WebSocket server to it on the same port. Many developers try to spin up socket servers on separate dedicated ports or use heavy framework wrappers like Socket.IO. Show the standard lightweight implementation using Node's standard `http` module and the mainstream Node WebSocket package. | fail→fail | 21,983 | 26,730 | +22% | 1 | 1 | 0% | 3,544 | 5,340 | +51% | 0 | 0 | — |
▸case-02 Write a TypeScript class or module for managing active real-time client socket connections in a backend service. A common approach is storing active socket references in an array or plain JavaScript object with dynamic keys. Provide the idiomatic data structure and type signature for mapping authenticated user IDs to their active socket instances. | fail→fail | 16,379 | 24,149 | +47% | 1 | 1 | 0% | 3,284 | 3,488 | +6% | 0 | 0 | — |
▸case-03 Write a TypeScript event listener for incoming real-time socket connections in Node.js. Developers often allow unauthenticated connections and wait for the client to send an authentication token in their first message payload. Show how to authenticate the user during the initial connection setup using the HTTP request object. | pass→pass | 22,528 | 14,729 | -35% | 1 | 1 | 0% | 3,419 | 3,180 | -7% | 0 | 0 | — |
▸case-04 Write a TypeScript event handler for the WebSocket 'message' event in Node.js. Incoming socket frames arrive as raw binary buffers or strings. Developers frequently pass the raw event payload directly into business logic or call JSON.parse directly on the Buffer object without explicit string conversion. Show the robust parsing procedure. | pass→pass | 21,875 | 19,421 | -11% | 1 | 1 | 0% | 3,317 | 3,210 | -3% | 0 | 0 | — |
▸case-05 Write a TypeScript broadcast function that iterates through all active client connections and sends a JSON payload to everyone. Model outputs frequently call client.send() directly on every tracked socket in a loop, which throws errors if a client is in a closing or closed state. Show the defensive status check required before calling .send(). | pass→pass | 15,721 | 11,795 | -25% | 1 | 1 | 0% | 1,932 | 1,679 | -13% | 0 | 0 | — |
▸case-06 Write a TypeScript listener for WebSocket socket disconnection events in a user-indexed backend connection registry. Developers often forget to clean up connection maps or rely on garbage collection, leading to memory leaks and attempts to send messages to dead sockets. Show how the connection mapping is updated when a client disconnects. | pass→pass | 24,197 | 19,834 | -18% | 1 | 1 | 0% | 3,746 | 3,428 | -8% | 0 | 0 | — |
▸case-07 Write a TypeScript utility function to broadcast an object payload to connected WebSocket clients. A common efficiency mistake is calling JSON.stringify(message) repeatedly inside the loop for every connected client. Show the optimal serialization pattern when preparing a payload for broadcast. | pass→pass | 15,988 | 11,711 | -27% | 1 | 1 | 0% | 2,107 | 1,658 | -21% | 0 | 0 | — |
▸case-08 Describe the architectural pattern and strategy for scaling a real-time WebSocket service horizontally across multiple server instances in a cluster. Developers often try to maintain sticky sessions or attempt to replicate raw socket connections across nodes. Explain the standard architecture recommended for distributing messages across multiple WebSocket server instances. | pass→pass | 25,693 | 24,066 | -6% | 1 | 1 | 0% | 3,487 | 3,681 | +6% | 0 | 0 | — |
▸case-09 Write a TypeScript snippet demonstrating how to detect and terminate broken or stale WebSocket connections that did not close cleanly in Node.js. Developers often assume TCP socket disconnects are always notified immediately, leaving ghost connections open indefinitely. Show the recommended application-level connection monitoring mechanism. | pass→pass | 16,717 | 9,060 | -46% | 1 | 1 | 0% | 2,262 | 2,141 | -5% | 0 | 0 | — |
▸case-10 Write a JavaScript function for client-side WebSocket connection maintenance when a connection drops unexpectedly. Naive implementations immediately attempt to reconnect in a tight infinite while loop or fixed 1-second interval, causing thundering herd problems on server restart. Outline the best practice strategy for client reconnection attempts. | pass→pass | 22,789 | 18,562 | -19% | 1 | 1 | 0% | 4,696 | 4,101 | -13% | 0 | 0 | — |
▸case-11 Design an architectural strategy for decoupling heavy background event processing from the WebSocket connection handler when handling high-throughput real-time updates. Developers often run expensive synchronous processing or database operations directly inside the WebSocket 'message' event handler, blocking the event loop. What component should sit between incoming socket messages and backend processing workers? | pass→pass | 24,856 | 23,041 | -7% | 1 | 1 | 0% | 3,250 | 3,127 | -4% | 0 | 0 | — |
▸case-12 Write a Node.js WebSocket message callback snippet in TypeScript that receives a RawData argument from the ws library 'message' event. Node developers often assume data is already a UTF-8 string or try to cast it as 'data as string'. Show the correct method call to convert the raw incoming frame buffer into a usable string before decoding. | pass→pass | 15,467 | 5,961 | -61% | 1 | 1 | 0% | 2,946 | 1,526 | -48% | 0 | 0 | — |
▸case-13 Write a TypeScript function to send a private notification message to a specific authenticated user by their userId in a Node.js WebSocket server. Developers often iterate over all connected sockets in an array and filter by socket custom properties. Show how to perform an O(1) lookup using the connection tracking collection. | fail→fail | 19,847 | 10,887 | -45% | 1 | 1 | 0% | 2,977 | 2,422 | -19% | 0 | 0 | — |
▸case-14 Write a TypeScript safety guard function that checks if a WebSocket instance is in a valid state to transmit data before sending. Developers often compare ws.readyState against numeric literals like 1 or string values like 'open'. Show the standard constant imported from the WebSocket library used for this readiness check. | pass→pass | 15,704 | 7,149 | -54% | 1 | 1 | 0% | 2,062 | 1,679 | -19% | 0 | 0 | — |
▸case-15 Write a TypeScript snippet showing how connection requests are authenticated when establishing a WebSocket session with Node's standard HTTP server. Developers often place authentication tokens in message body frames after the socket opens. Show how the HTTP upgrade request object req is passed during the server 'connection' event to authenticate before registering the connection. | fail→pass | 18,725 | 16,860 | -10% | 1 | 1 | 0% | 2,677 | 2,808 | +5% | 0 | 0 | — |
▸case-16 Explain how to structure real-time chat application architecture using a pub/sub pattern rather than directly wiring socket message handlers to database writes and message dispatching. Developers often tightly couple socket handlers directly to channel routing logic in a single file. Outline the recommended structural approach. | pass→pass | 29,156 | 24,809 | -15% | 1 | 1 | 0% | 3,791 | 3,969 | +5% | 0 | 0 | — |
▸case-17 Write a TypeScript connection event handler that sets up message listeners and cleanup logic for a newly connected WebSocket client. Developers often attach cleanup logic to window unload or TCP end events rather than the socket lifecycle events. Show the specific socket event listener used to remove the client from active tracking when the socket terminates. | pass→pass | 11,089 | 17,665 | +59% | 1 | 1 | 0% | 2,157 | 2,831 | +31% | 0 | 0 | — |
▸case-18 Write a TypeScript helper function sendJson that takes a WebSocket instance and an object payload, and transmits it safely. Developers often pass JavaScript object literals directly into ws.send(), which fails because WebSockets only transmit strings or binary buffers. Show the required serialization step before calling .send(). | pass→pass | 13,500 | 12,547 | -7% | 1 | 1 | 0% | 1,600 | 1,771 | +11% | 0 | 0 | — |
▸case-19 Write Node.js code in TypeScript to initialize both an HTTP server and a WebSocket server on port 3000. Many tutorials suggest running Express on port 3000 and WebSockets on port 3001, causing CORS and firewall complications. Show how both protocol handlers share the single HTTP server instance. | pass→pass | 17,521 | 12,626 | -28% | 1 | 1 | 0% | 2,519 | 3,133 | +24% | 0 | 0 | — |
▸case-20 Write an Express.js HTTP route handler in TypeScript that streams real-time server-side updates to web clients using Server-Sent Events (SSE). Do not use WebSockets or external socket libraries. Show the HTTP response headers required for a persistent unidirectional event stream. | pass→pass | 11,584 | 12,104 | +4% | 1 | 1 | 0% | 2,398 | 1,765 | -26% | 0 | 0 | — |
▸case-21 Write a JavaScript snippet that initializes a WebRTC peer-to-peer media connection in the browser to stream camera video between two users. Do not set up a WebSocket server. Show how to create the native RTCPeerConnection object with STUN server configuration. | pass→pass | 17,374 | 13,647 | -21% | 1 | 1 | 0% | 2,504 | 2,183 | -13% | 0 | 0 | — |
▸case-22 Write an HTTP REST API endpoint handler in Express/TypeScript for fetching live system metrics where clients poll the endpoint every 5 seconds. The endpoint should support HTTP conditional GET requests to save bandwidth when metrics haven't changed. Show how to set the ETag response header and check If-None-Match. | pass→pass | 23,089 | 13,542 | -41% | 1 | 1 | 0% | 3,557 | 3,065 | -14% | 0 | 0 | — |