Skip to content

Fix React error #310: Add missing useMemo dependency array#3

Open
railway-app[bot] wants to merge 40 commits into
mainfrom
railway/code-change-1kKMiU
Open

Fix React error #310: Add missing useMemo dependency array#3
railway-app[bot] wants to merge 40 commits into
mainfrom
railway/code-change-1kKMiU

Conversation

@railway-app

@railway-app railway-app Bot commented Jun 4, 2026

Copy link
Copy Markdown

Problem

The PlatformContext.Provider in App.tsx used React.useMemo() to memoize its context value, but the copyLiveMatchLink entry was wrapped in an inline arrow function: copyLiveMatchLink: (matchId: string) => { void copyLiveMatchLink(matchId); }. This inline wrapper creates a brand-new function reference on every render, meaning the memoized object is never stable — it always produces a new value, causing React error #310 (invalid hook call / stale closure loop) during component initialization.

Solution

Replaced the inline arrow wrapper with a direct reference to copyLiveMatchLink, which is already a stable useCallback-memoized function returned from useMatchEngine. The dependency array already listed copyLiveMatchLink directly, so the object and its deps are now fully consistent. TypeScript accepts the async function where (matchId: string) => void is expected, so no type changes are needed.

Changes

  • Modified apps/web/src/App.tsx

Generated by Railway

jraya106 added 30 commits May 14, 2026 19:53
…im validation, dead-room reconciliation, and full beta reset
…esence, castling fusion

- Fix TS structural errors in App.tsx (orphan </div> from ErrorBoundary/ELO removal)
- Replace PlatformContext createContext<any> with typed PlatformContextShape interface
- Add TLS support to gateway (TLS_CERT_FILE/TLS_KEY_FILE env vars)
- Add disconnect presence on WS close (MarkDisconnected + playerId/playerSecret query params)
- Fix castling to use isAttackedWithFusion instead of isAttacked for fusion-aware checks
- Remove ELO stakes section (hardcoded +16/-16 replaced by proper ELO formula)
- Add resign confirmation (two-click with 3s timeout and red highlight)
- Add draw offer cooldown (15s rate limit on both client and server)
- Add idempotency keys (clientMoveId) to prevent duplicate intent processing
…, queue outbox, security headers, orphaned client removal

CRITICAL:
- HTTP timeouts (ReadHeaderTimeout/ReadTimeout/WriteTimeout/IdleTimeout) on all 4 Go servers
- WebSocket CheckOrigin rejects empty Origin (CORS bypass fixed)
- Hardcoded defaultAllowedOrigins removed from match-service
- Queue TOCTOU race: CreateMatch HTTP call moved outside mutex via goroutine
- USER nobody added to all 5 Dockerfiles (Go + web)
- Security headers in next.config.mjs (CSP, X-Frame-Options, etc.)
- web.Dockerfile CMD uses exec for proper signal handling
- legalMovesWithFusion in applyMove intent validation (castling fusion)
- Rate limiter middleware (IP-based, windowed) applied to all 4 services
- Elo-range matchmaking (max 400 rating diff in findMatchCandidateLocked)
- Orphaned client/ directory removed (duplicate CRA frontend)
- Test ref: collectBroadcasts -> collectAndBroadcast

HIGH:
- In-memory rate limit package (internal/rate_limit) with configurable window/limit
- Default rate limits: 60/min API, 20/10min auth, 10/30s queue
- Elo-range matching for casual and rated queues
- Session token hashing infrastructure (hashSessionToken function)
- Add inBounds checks to fakepiece/clone/teleport/jump card targets (4 crash fixes)
- Deep-copy History and SeenClientMoveIDs in cloneState (2 data race fixes)
- Harden platform-service: status endpoint, account enumeration, sensitive logging, X-Forwarded-For spoofing
- Add history_public.go DTO layer and public API endpoints
- Unify ELO formula across all backends (Postgres, SQLite, in-memory)
- Fix guest-results and account-results tests for new auth-required handler
- Fix lava test (insufficient material draw)
- Use url.pathname instead of hardcoded routes in syncRequestedProfileQuery
  and syncRequestedHistoryQuery to prevent URL rewrite when leaving History
- Rename 'nobody' user to 'chess404' in all 4 Go Dockerfiles to fix Alpine
  3.20 conflict with built-in nobody user
…vate match queue, bootstrap claim, page slowness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants