From 13cbcf5ed3ba94c3e1d1a3ed29f7569f3fd7a74e Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Wed, 19 Aug 2026 20:25:01 +0200 Subject: [PATCH] fix(espidf): run library resolution/merge off the event loop _resolve_library_components does minutes of synchronous filesystem work for a big library (FastLED: BFS over every header + copying thousands of files) directly inside async compile(), starving the event loop: the /api/compile/start response never flushed and clients timed out at 30s while the build itself was healthy. Run it via asyncio.to_thread like the cmake and ninja steps already do. --- backend/app/services/espidf_compiler.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/app/services/espidf_compiler.py b/backend/app/services/espidf_compiler.py index 4c9c83d7..60817444 100644 --- a/backend/app/services/espidf_compiler.py +++ b/backend/app/services/espidf_compiler.py @@ -3668,7 +3668,13 @@ class ESPIDFCompiler: # / OSS self-host. arduino_libs = libraries_dir or self._find_arduino_libraries_dir() - component_names, _ = self._resolve_library_components( + # Heavy sync filesystem work (BFS header resolution + copying + # thousands of library files — FastLED alone takes minutes). + # Run it off the event loop like cmake/ninja below, or the + # loop starves: /compile/start responses never flush and the + # client dies on its 30s timeout while the build is fine. + component_names, _ = await asyncio.to_thread( + self._resolve_library_components, ext_headers, arduino_libs, esp32_libs, arduino_comp_name, user_libs_dir, allowed_libraries=allowed_libraries,