# Bug #24: HuggingFace Space Stuck on "Loading..." (P0) **Date:** 2025-12-09 **Status:** FIXED **Branch:** `debug/hf-spaces-loading-forever` **Space:** https://huggingface.co/spaces/VibecoderMcSwaggins/stroke-deepisles-demo --- ## Symptom The HuggingFace Space shows: - **Status badge:** "Running on T4" (green) ✓ - **App panel:** Stuck on "Loading..." indefinitely ✗ The Docker container has started successfully (hence "Running on T4"), but the Gradio frontend never receives a response from the backend. --- ## What We Know ### Local Testing: Works Fine ```python # All pass in ~1.3 seconds from stroke_deepisles_demo.ui.app import create_app demo = create_app() # Returns gr.Blocks successfully ``` ### Code on HF Space The Space is synced with `main` branch (commit `10a72ea`), NOT the PR #23 branch. - `js_on_load` parameter was already added in commit `bc1d8e8` - Server binds to `0.0.0.0:7860` (correct for Docker) - Dataset loading uses pre-computed case IDs (no network calls on startup) ### Configuration Verified | Setting | Value | Status | |---------|-------|--------| | `sdk` | `docker` | ✓ Correct | | `app_port` | `7860` | ✓ Correct | | `server_name` | `0.0.0.0` | ✓ Correct | | `server_port` | `7860` | ✓ Correct | | Gradio version | `>=6.0.0,<7.0.0` | ✓ Correct | --- ## Hypotheses ### H1: Python Startup Crash (Silent) The Python app may be crashing during startup but HF Spaces still shows "Running on T4" because the container process is alive (perhaps a shell wrapper). **Check:** Look at HF Spaces logs for Python tracebacks. ### H2: Gradio Server Not Binding The Gradio server may be failing to bind or timing out before accepting connections. **Check:** Look for "Running on local URL" in logs. ### H3: HF Spaces Platform Issue HuggingFace Spaces may have a platform-wide issue affecting Docker SDK spaces. **Check:** https://status.huggingface.co/ and HF Forums. ### H4: Memory/Resource Exhaustion The T4 instance may be running out of memory during startup. **Check:** Look for OOM errors in logs. ### H5: Dependencies Installation Failure The `git+https://github.com/CloseChoice/datasets.git@...` dependency may fail to install. **Check:** Build logs for pip install errors. --- ## Diagnostic Steps ### 1. Check HF Spaces Logs Go to the Space → Settings → Logs and look for: - Python tracebacks - "Running on local URL: http://0.0.0.0:7860" - Memory errors - Dependency installation errors ### 2. Factory Rebuild Settings → Factory rebuild to force a clean Docker build. ### 3. Check HF Status Visit https://status.huggingface.co/ for platform outages. ### 4. Test Minimal Dockerfile Create a minimal test Space with just Gradio to isolate the issue: ```dockerfile FROM python:3.11-slim RUN pip install gradio COPY <` tag instead of dynamic `import()`: ```python with gr.Blocks( head='' ) as demo: ... ``` Or use the global `js` parameter on `gr.Blocks` to define initialization code that runs after the script loads.