Skip to content

Conversation

willmmiles
Copy link
Member

@willmmiles willmmiles commented Jul 31, 2025

Update to the latest upstream AsyncTCP library, which now includes most of the improvements from the willmmiles fork, and specifically includes a fix for the crashes reported at #4785. (It is my intention to PR the remaining improvements from my fork there anyways; the additional scrutiny has been good for turning up bugs.)

Unfortunately, AsyncWebServer also must be updated with the same reference: if it points to a different library source, the PlatformIO build process can get quite confused.

Summary by CodeRabbit

  • Chores
    • Updated ESPAsyncWebServer and AsyncTCP library versions to newer releases for improved compatibility and performance.

This should fix (or at least improve) some of the crash cases under
excessive web server load.
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

The PlatformIO configuration file was updated to specify newer versions and sources for the ESPAsyncWebServer and AsyncTCP libraries. The ESPAsyncWebServer dependency was bumped to v2.4.2, and the AsyncTCP dependency for the esp32_all_variants environment was switched to a different repository and updated to v3.4.7. Additionally, a new build flag was added for the esp32_all_variants environment.

Changes

Cohort / File(s) Change Summary
PlatformIO Dependency Updates
platformio.ini
Updated ESPAsyncWebServer to v2.4.2 globally; changed AsyncTCP for esp32_all_variants to esp32async/AsyncTCP v3.4.7; added build flag -D CONFIG_ASYNC_TCP_STACK_SIZE=8192 for esp32_all_variants.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e374c7a and f74d145.

📒 Files selected for processing (1)
  • platformio.ini (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • platformio.ini
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_160)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b76ef23 and 9e4675e.

📒 Files selected for processing (1)
  • platformio.ini (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: blazoncek
PR: wled/WLED#4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.
platformio.ini (1)

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_160)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
🔇 Additional comments (1)
platformio.ini (1)

145-145: Inconsistent ESPAsyncWebServer version pinning – please confirm it’s intentional

The global lib_deps block (platformio.ini line 145) now pins ESPAsyncWebServer to v2.4.1, while the compat environment (platformio.ini line 233) still references v2.4.0. This split could introduce subtle ABI/feature mismatches at link-time if it wasn’t deliberate.

• platformio.ini:145 → https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.1
• platformio.ini:233 → https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.0

If you intended to upgrade all environments, please align both pins to the same version.

@netmindz
Copy link
Member

When we are happy this is good to merge, should it also get merged to 0_15_x ?

@willmmiles
Copy link
Member Author

When we are happy this is good to merge, should it also get merged to 0_15_x ?

Depends on how long that takes ;)

Honestly I'd recommend moving quickly on this one; feedback on AsyncTCP 3.4.6 has been extremely encouraging.

@DedeHai
Copy link
Collaborator

DedeHai commented Jul 31, 2025

btw. the lockup I saw in the UI were, as you predicted, purely heap related. With my latest fixes on that PR it is very stable. Would not call it rock solid yet but maybe this update to AsyncTCP will make it so.

@willmmiles
Copy link
Member Author

btw. the lockup I saw in the UI were, as you predicted, purely heap related. With my latest fixes on that PR it is very stable. Would not call it rock solid yet but maybe this update to AsyncTCP will make it so.

It turned out that there were two bugs in AsyncTCP: a use-after-free if a connection was dropped due to overload at the TCP layer, and a race condition that could result in a double-free if the remote end closed the connection just after sending data completed. In both cases the result was memory corruption that typically manifested as crashes in heap functions, as heap data structures (and guard segments) were getting overwritten.

Bugfix on 3.4.6
@willmmiles
Copy link
Member Author

Updated after another AsyncTCP bug fix (memory leak handling aborted connections such as Firefox attempting SSL even when given an http:// URL)

We downtuned the stack usage of AsyncTCP, and at some point in the
history of our fork, this got folded in to the default.  Re-apply the
stack size we've been using and recover that RAM.
@willmmiles willmmiles merged commit 3f90366 into wled:main Aug 9, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants