[web_server] Increase httpd task stack size to prevent stack overflow

The SerializationBuffer introduced in #13625 places a 640-byte buffer
on the stack. When handling HTTP requests on the ESP-IDF httpd task
(which has a default stack of 4096 bytes), the deep call chain from
handleRequest through JSON serialization and lwip_send can overflow.

Increase the httpd task stack by 256 bytes to restore headroom.

Fixes #14991
This commit is contained in:
J. Nick Koston
2026-03-19 18:54:22 -10:00
parent 02ada93ea5
commit b877b4a57e
@@ -121,7 +121,11 @@ void AsyncWebServer::begin() {
if (this->server_) {
this->end();
}
// Default httpd stack is 4096. Increase to accommodate SerializationBuffer's
// 640-byte stack buffer used by web_server JSON request handlers.
constexpr size_t HTTPD_STACK_SIZE = 4096 + 256;
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.stack_size = HTTPD_STACK_SIZE;
config.server_port = this->port_;
config.uri_match_fn = [](const char * /*unused*/, const char * /*unused*/, size_t /*unused*/) { return true; };
// Always enable LRU purging to handle socket exhaustion gracefully.