Skip to content

Commit 30bb05a

Browse files
stephencelismluisbrown
authored andcommitted
Fix long-living effect leak (#1338)
`Store.send` is currently spinning up a task for every batch of actions sent through it, even if no effects are in-flight. This issue compounds itself recursively when long-living effects feed actions back into the store. Instead, let's only spin up tasks when we need to. Fixes #1337 (cherry picked from commit e407d7e418cff6b75f4d052d53bc679781b19885)
1 parent b9806ff commit 30bb05a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Sources/ComposableArchitecture/Store.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ public final class Store<State, Action> {
408408
}
409409
}
410410

411+
guard !tasks.wrappedValue.isEmpty else { return nil }
411412
return Task {
412413
await withTaskCancellationHandler {
413414
var index = tasks.wrappedValue.startIndex

0 commit comments

Comments
 (0)