How a COEP header silently killed a browser-based WASM image compressor in production
A development team shipping a privacy-focused, browser-side image compressor built with Rust, WASM, and WebGPU encountered a critical production failure after enabling cross-origin isolation headers. Activating Cross-Origin-Embedder-Policy with 'require-corp' caused all compression formats — JPG, PNG, WebP, and AVIF — to crash simultaneously, as nested rayon workers spawned by the multi-threaded WASM build were blocked by COEP. The bug was invisible in local and staging environments because it only surfaced under real cross-origin isolation, making it difficult to detect before reaching production traffic. The root cause was a flawed logic gate that automatically loaded the multi-threaded package whenever crossOriginIsolated was true, meaning the same header enabling shared memory also triggered the code path that COEP then blocked. The fix involved three loader-level changes: decoupling thread usage from COI detection behind an explicit user opt-in, defaulting to a single-threaded WASM build, and adding a self-healing fallback that retries on the safe path if a worker crashes.
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