Skip to content

Always cleanup children#22

Merged
cowboyd merged 2 commits intomasterfrom
always-cleanup-children
Oct 30, 2019
Merged

Always cleanup children#22
cowboyd merged 2 commits intomasterfrom
always-cleanup-children

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented Oct 30, 2019

When debugging an effection application, we noticed that in the case where you had halted children, they were not being removed from parents that were still running. That meant that you have a fork tree looking like:

Fork {
   state: waiting
   operation: main
   children:
     Fork {
       state: running
       operation:
       children:
     }
     Fork {
       state: running
       operation:
       children:
           Fork {
             state: halted
             operation: setupConnection
             children:
           }
     }
}

Which means that if the the parent is long running, then you can accrue lots of halted children which is a memory leak.

This makes sure that every time that a child joins its parent, it is removed from the list of children. This is safe because join only happens on finalization of a child.

When you have the case of a parent A that is running, and also that
parent has a forked child `B` that becomes halted. A, because it is
still yielding should continue running. If on the other hand, `A` is
waiting, then it should be completed because that was the last
blocking child.

```
A
 - B
```

Howewer, we only checked that the parent did not have blocking
children, and not that it was also just waiting (and not running).

This adds the check to the `join()` method to ensure that running
parents continue running even when a child is halted.
When debugging an effection application, we noticed that in the case
where you had halted children, they were not being removed from
parents that were still running. That meant that you have a fork tree
looking like:

```
Fork {
   state: waiting
   operation: main
   children:
     Fork {
       state: running
       operation:
       children:
     }
     Fork {
       state: running
       operation:
       children:
           Fork {
             state: halted
             operation: setupConnection
             children:
           }
     }
}
```

Which means that if the the parent is long running, then you can
accrue lots of halted children which is a memory leak.

This makes sure that _every_ time that a child joins its parent, it is
removed from the list of children. This is safe because join _only_
happens on finalization of a child.
@frontsidejack
Copy link
Copy Markdown
Member

A preview package of this pull request has been released to NPM with the tag always-cleanup-children.
You can try it out by running the following command:

$ npm install effection@always-cleanup-children

or by updating your package.json to:

{
  "effection": "always-cleanup-children"
}

Once the branch associated with this tag is deleted (usually once the PR is merged or closed), it will no longer be available. However, it currently references effection@0.3.1-2f60e15 which will be available to install forever.

Generated by 🚫 dangerJS against 2a0924c

@cowboyd cowboyd merged commit 5598a2e into master Oct 30, 2019
@cowboyd cowboyd deleted the always-cleanup-children branch October 30, 2019 20:42
jnicklas added a commit that referenced this pull request Feb 24, 2021
taras added a commit that referenced this pull request Aug 24, 2025
…solution

Added support for imports, relative imports and multiple entry points
taras pushed a commit that referenced this pull request Nov 12, 2025
taras added a commit that referenced this pull request Nov 12, 2025
…solution

Added support for imports, relative imports and multiple entry points
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.

2 participants