[web_server_idf] Build state documents in a stack arena so a state event does no heap allocation (#19383)

This commit is contained in:
J. Nick Koston
2026-09-30 11:10:40 +13:00
committed by GitHub
parent 5502f620d4
commit 25ddc94d5d
9 changed files with 375 additions and 19 deletions
+12
View File
@@ -1,3 +1,6 @@
import functools
from esphome.components.json import enable_arena
from tests.testing_helpers import ComponentManifestOverride
@@ -7,3 +10,12 @@ def override_manifest(manifest: ComponentManifestOverride) -> None:
# library registration to happen, otherwise json_util.cpp fails to find
# ArduinoJson.h.
manifest.enable_codegen()
# The JsonArena host test needs the arena compiled in, as a consumer would request it
real_to_code = manifest.to_code
@functools.wraps(real_to_code)
async def to_code_with_arena(config):
await real_to_code(config)
enable_arena()
manifest.to_code = to_code_with_arena