Skip to content

Postpone handle child terminated#1125

Merged
varsill merged 7 commits into
masterfrom
postpone_handle_child_terminated
May 13, 2026
Merged

Postpone handle child terminated#1125
varsill merged 7 commits into
masterfrom
postpone_handle_child_terminated

Conversation

@varsill
Copy link
Copy Markdown
Contributor

@varsill varsill commented Apr 22, 2026

This PR:

  • makes sure that handle_child_terminated is only called when given components subprocess supervisor is already dead

@varsill varsill added the no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md label Apr 23, 2026
@varsill varsill marked this pull request as ready for review April 23, 2026 09:36
@varsill varsill requested a review from mat-hek as a code owner April 23, 2026 09:36
@varsill varsill self-assigned this Apr 23, 2026
@varsill varsill added this to Smackore Apr 23, 2026
@varsill varsill moved this to In Review in Smackore Apr 23, 2026
Comment on lines +268 to +270
update_in(state, [:children, data.supervisor_pid], fn supervisor_data ->
Map.put(supervisor_data, :pending_child_death, {data.name, reason})
end)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about

Suggested change
update_in(state, [:children, data.supervisor_pid], fn supervisor_data ->
Map.put(supervisor_data, :pending_child_death, {data.name, reason})
end)
put_in(state.children[data.supervisor_pid].pending_child_death, {data.name, reason})

Also, initialise the pending_child_death to nil in handle_call(:start_component, ...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +253 to +259
case data do
%{pending_child_death: {child_name, death_reason}} ->
Message.send(state.parent_component, :child_death, [child_name, death_reason])

_no_pending_death ->
:ok
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move the case out of the parent case. Both can also be refactored to withs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@varsill varsill merged commit f121922 into master May 13, 2026
6 of 7 checks passed
@varsill varsill deleted the postpone_handle_child_terminated branch May 13, 2026 09:32
@github-project-automation github-project-automation Bot moved this from In Review to Done in Smackore May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants