SShortSingh.
Back to feed

How a pub quiz app fixed WebSocket reconnects that left players stuck for ages

0
·60 views

A live pub quiz platform serving around 100 simultaneous players over a single venue WiFi discovered that brief two-second connection drops were causing phones to show 'Reconnecting' for far longer than expected. The root cause was a stale closure bug: the WebSocket onclose handler was reading React state inside a setState updater, which delayed side effects like scheduling a reconnect until after reconciliation. The fix involved mirroring status into a React ref so the handler could read current state and act on it immediately, outside React's update cycle. Separately, the polling fallback interval was doubled from five to ten seconds after engineers calculated that 100 phones polling every five seconds generated roughly 1,200 requests per minute from one IP address, exceeding rate limits and knocking out the entire venue. The team accepted slightly stale data in degraded mode as a deliberate trade-off, reasoning that a lagging leaderboard is less harmful than a complete service outage.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Method for diffing large 834 enrollment files without crashing Excel

Working with enrollment files that run to hundreds of megabytes can freeze Notepad++ or cause Excel to truncate data, which makes routine month-over-month comparisons hard. The article proposes a member-level approach: split each file into member records at INS segments, build a stable key per member, and store a hash and file offset for each. Streaming the new file against that index classifies members as added, unchanged, changed, or possibly termed while keeping memory tied to member count rather than file size. It also warns that full and change 834 files must be treated differently, since an absent member means termination in one but not the other. A small free command-line tool, x12diff, is presented as an implementation that detects the file type from BGN08.

0
ProgrammingDEV Community ·

Cursor AI can receive your workspace folder path before any tool runs

A new Cursor chat can be given the absolute path of the opened workspace folder, even before the agent opens any file. Parent directory names may reveal details such as a local account name, a client relationship, or business activity. Cursor staff confirmed this in a November 12, 2026 forum reply, noting that project-specific directories under the user's home folder can also enter context. Knowing a location does not grant permission to read it, and .cursorignore only controls indexing rather than acting as a data-loss-prevention control. The article advises checking what a fresh chat reveals, reviewing the chat context, and renaming or relocating folders whose names leak sensitive details.

0
ProgrammingDEV Community ·

OpenID4VCI 1.0 Final Errata, 1.1 Draft and Server-to-Server Specs Diverge in Late 2026

An analysis of the OpenID4VCI credential issuance standard finds that the approved 1.0 Final text leaves gaps: a Wallet receives the same invalid_grant error for a wrong PIN and an expired Pre-Authorized Code, and the text sets no limit on PIN guesses. Fixes have since appeared in separate documents, including a 1.0 errata set, a 1.1 editor's draft, and a server-to-server draft merged in August 2026, so implementers may follow different texts. The author checked the specification against its repository at a commit dated 27 October 2026 and reviewed the cited pull requests on 15 November 2026. The article also walks through the protocol's roles, endpoints and pre-authorized code flow, including the credential offer format and the token request.

0
ProgrammingDEV Community ·

Cómo construir un agente de IA con Google ADK

Un tutorial explica cómo pasar de los conceptos de la IA agéntica a una implementación práctica usando Google Agent Development Kit (ADK), un framework de código abierto para crear agentes mediante código. El ejemplo consiste en un Asistente de Políticas Corporativas que responde preguntas en lenguaje natural sobre documentos internos de áreas como Recursos Humanos, Finanzas y Seguridad. El agente consulta documentos almacenados en Google Drive, recupera la información relevante y responde citando sus fuentes originales. La solución combina Gemini como modelo de lenguaje, Streamlit para una interfaz tipo chatbot y una estrategia RAG basada en búsqueda léxica sobre un índice en memoria, sin necesidad de base de datos vectorial.