fix: isolate callback failures from HTTP workers - #69
Merged
Conversation
hjianbo
marked this pull request as ready for review
September 2, 2026 03:40
zmstone
reviewed
Sep 2, 2026
zmstone
reviewed
Sep 2, 2026
zmstone
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a robustness fix for the ehttpc worker pool.
Async callbacks are provided by callers, so an exception in callback code must not be able to take down the HTTP transport worker. Before this change, callbacks were evaluated directly in the ehttpc worker process. An unexpected upstream response could therefore kill a worker, and repeated failures could exhaust the supervisor restart intensity and leave the whole pool unavailable until the resource was restarted.
The fix keeps callback failures contained while preserving the existing request representations on both synchronous and asynchronous hot paths. Invalid callback shapes are rejected before dispatch, and malformed callback values cannot be passed to gen_server:reply/2. Callback failures are logged without including the HTTP response payload.
What changed
Reference incident
The business-level response parsing problem is tracked separately in emqx/emqx_whc#142. This PR is the ehttpc-side robustness fix.
The following redacted excerpts from that incident show why callback failures must not be allowed to terminate the shared pool: