Skip to content

Commit

Permalink
Merge pull request #241 from Workiva/revert-239-unload-modules-loaded…
Browse files Browse the repository at this point in the history
…-after-unload-starts

Revert "Ensure all child modules get unloaded"
  • Loading branch information
rmconsole3-wf authored Mar 1, 2024
2 parents db71a2d + 408f44c commit 6db8367
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/src/lifecycle_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1124,20 +1124,12 @@ abstract class LifecycleModule extends SimpleModule with Disposable {
_activeSpan = _startTransitionSpan('unload');

_willUnloadController.add(this);

// We're looping here because it's possible for additional child modules to be added to this list while we are
// unloading the current items. While loadChildModule is guarded from adding new modules after unload starts,
// it contains asynchronous elements that allow a module to be added to this list during the unload.
// Note that items get removed from this list by an event handler listening to their didDispose stream.
while (_childModules.isNotEmpty) {
await Future.wait(_childModules.toList().map((child) {
child.parentContext = _activeSpan?.context;
return child.unload().whenComplete(() {
child.parentContext = null;
});
}));
}

await Future.wait(_childModules.toList().map((child) {
child.parentContext = _activeSpan?.context;
return child.unload().whenComplete(() {
child.parentContext = null;
});
}));
try {
await onUnload();
} catch (error, stackTrace) {
Expand Down

0 comments on commit 6db8367

Please sign in to comment.