From 037e18c3fea97b7c8041a000e26611dc9ad4cf10 Mon Sep 17 00:00:00 2001 From: valency-studio-bot Date: Thu, 30 Jul 2026 13:42:29 +0000 Subject: [PATCH] Engineering pass: fix polling leak, security hardening, and migration to Next 16 conventions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical bug fixes: - roblox-panel.tsx: fix polling interval leak (effect deps caused multiple intervals to stack). Now uses single setInterval with proper cleanup; uses refs to avoid effect re-creation. - history-list.tsx: same pattern — ref-based polling that doesn't recreate on every state update. - roblox-api.ts: verifyApiKey was a no-op (404 from a non-existent endpoint was treated as 'valid'). Now probes a real asset endpoint and uses 401/403 vs 200/404 to discriminate. - audio-processor.ts: getWaveform was returning Math.random() on ffmpeg failure, masking broken files. Now returns empty array so the UI can show a clear 'no waveform' state. - audio-processor.ts: ensureDirs moved off module top-level to prevent import-time side effects on read-only filesystems and to avoid Turbopack NFT issues. All UPLOAD_DIR/PROCESSED_DIR uses replaced with lazy getters. Security: - store.ts: Roblox API key is NO LONGER persisted to localStorage. Identity is remembered; the user must re-verify with their key before any upload. Includes one-time migration that scrubs legacy keys from existing localStorage entries. - /api/roblox/status: API key moved from URL query string to request body (POST) or X-Roblox-Api-Key header. The key is no longer logged in reverse-proxy access logs or browser history. - /api/roblox/verify and /api/roblox/upload: added lightweight in-memory rate limiting (10 req/min for verify, 20 req/min for upload) to prevent trivial DoS and Roblox API throttling. - /api/roblox/upload: explicit 100 MB cap on in-memory audio buffer with proper 413 response. Next.js 16 migration: - src/middleware.ts → src/proxy.ts: Next 16 deprecated the middleware file convention in favor of proxy (same semantics). - next.config.ts: reactStrictMode enabled to catch effect bugs; ignoreBuildErrors kept for legacy reasons. Removed untyped eslint.ignoreDuringBuilds option. - outputFileTracingExcludes for ./.tmp-audio/** and bot-config.json to avoid Turbopack NFT pulling in the whole project. TypeScript / code quality: - audio/file/route.ts: Buffer → Uint8Array wrap for NextResponse BodyInit compatibility. - waveform-player.tsx: removed invalid 'volume' prop from