--- id: TASK-85 title: 'Fix folk-wrapper crash, service worker API exclusion, fal.ai image-gen' status: Done assignee: [] created_date: '2026-03-03 07:43' labels: - bugfix - canvas - service-worker - ai dependencies: [] references: - lib/folk-wrapper.ts - website/sw.ts - server/index.ts priority: high --- ## Description Three fixes: 1. folk-wrapper.ts createRenderRoot() crashed with "Cannot read properties of null (reading 'appendChild')" — innerHTML="" removed the slot from DOM, making parentElement null on the next line. Fixed by saving parent ref before clearing. 2. Service worker (sw.ts) only excluded /api/ at root path, not module API paths like /jeff/rcal/api/events. These got cached and when network failed, catch handler returned undefined instead of a Response. Fixed with includes("/api/") and proper fallback Response. 3. Image generation returned 502 "No image returned" — queue.fal.run is async (returns request_id), not the actual image. Changed to synchronous fal.run endpoint for all three fal.ai endpoints (image-gen, t2v, i2v). ## Final Summary Fixed folk-wrapper parentElement null crash, service worker module API path exclusion with proper offline fallback, and fal.ai endpoint from queue.fal.run to fal.run for synchronous image/video generation. Committed as fef419f.