fix: Handle stray :DOWN messages in LogAccumulator#31
Open
erik-the-implementer wants to merge 5 commits intomainfrom
Open
fix: Handle stray :DOWN messages in LogAccumulator#31erik-the-implementer wants to merge 5 commits intomainfrom
erik-the-implementer wants to merge 5 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When block_until_any_task_ready receives a task result {ref, result},
it removes the ref from pending_tasks. The subsequent :DOWN message for
that same task process then arrives via handle_info, but the guard
is_map_key(state.pending_tasks, ref) fails since the ref was already
removed. With no catch-all clause, this causes a FunctionClauseError
crash.
Three fixes applied:
1. handle_info({ref, result}, state) now properly demonitors the task
and removes the ref from pending_tasks (previously it did neither
despite a comment saying it did)
2. block_until_any_task_ready now demonitors with flush when receiving
a task result, preventing the orphaned :DOWN message
3. Added catch-all handle_info clause as safety net for any stray
messages that slip through edge cases
Closes #18
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exercises the code path where block_until_any_task_ready consumes task results, generating stray :DOWN messages that previously crashed the LogAccumulator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
FunctionClauseErrorcrash inLogAccumulatorwhen receiving:DOWNmessages for task refs that have already been cleaned up byblock_until_any_task_readypending_tasksin all code paths that handle task completionhandle_infoclause as safety net for any remaining edge casesRoot cause
The
LogAccumulatorhas two code paths that consume task completion messages:handle_info/2— via the normal GenServer message loopblock_until_any_task_ready/1— via a rawreceiveblock when blocking on concurrent request limitsWhen
block_until_any_task_readyreceived{ref, result}, it removed the ref frompending_tasks. The subsequent:DOWNmessage for that same process then arrived viahandle_info, but with the ref no longer inpending_tasks, the guard failed and no catch-all existed — causing the crash.Additionally,
handle_info({ref, result}, state)had a comment saying "Remove the task from the pending tasks map" but the actual code returnedstateunchanged.Test plan
max_buffer_size=1andotlp_concurrent_requests=1to force theblock_until_any_task_readycode pathCloses #18
🤖 Generated with Claude Code