-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix]: use weak reference to internal sinks when vending to clients #189
Conversation
@@ -198,12 +198,11 @@ extension WorkflowNode.SubtreeManager { | |||
func makeSink<Action>(of actionType: Action.Type) -> Sink<Action> where Action: WorkflowAction, WorkflowType == Action.WorkflowType { | |||
let reusableSink = sinkStore.findOrCreate(actionType: Action.self) | |||
|
|||
let signpostRef = SignpostRef() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated change, but figured we might as well not instantiate this here since it isn't necessarily going to be used (we could also further improve this with some additional changes).
@@ -243,6 +243,26 @@ final class SubtreeManagerTests: XCTestCase { | |||
XCTAssertEqual(manager.sideEffectLifetimes.count, 1) | |||
XCTAssertEqual(manager.sideEffectLifetimes.keys.first, "key-2") | |||
} | |||
|
|||
func test_eventPipes_notRetainedByExternalSinks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed this fails prior to the change introduced in this PR
|
||
XCTAssertNotNil(externalSink) | ||
XCTAssertNil(weakEventPipe) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
* main: [fix]: use weak reference to internal sinks when vending to clients (#189) [feat]: add primary associated types to more protocols (#188) [chore]: pre major version bump cleanup (#187) [chore]: bump minimum deployment & swift versions (#186) Abstract ViewEnvironment to shared framework (#185) Bump activesupport from 6.1.4.4 to 6.1.7.1 (#183) [feat]: add primary associated types to `Workflow` protocol (#181) [chore]: update swiftformat ifdef indent rule to no-indent (#182)
…ow-workflow-conformance * origin/main: Expose AnyScreen.wrappedScreen for inspection (#193) Improve introspection for SignalProducerWorkflow actions (#192) [release]: bump version to 2.2.0 & remove separate concurrency version (#191) [feat]: add runtime observation API (#168) [chore]: refactor some internal actions to use existential any (#190) [fix]: use weak reference to internal sinks when vending to clients (#189) [feat]: add primary associated types to more protocols (#188) [chore]: pre major version bump cleanup (#187) [chore]: bump minimum deployment & swift versions (#186) Abstract ViewEnvironment to shared framework (#185)
Description
previously we would allow a strong reference to the internal
ReusableSink
to be captured by theSink
types that are vended to clients. this meant that events sent into such 'external' sinks would still propagate through the event handling machinery a bit before realizing that the backing workflow node to which they were destined was no longer around. by using weak references we can prevent extending the life of the internal sinks (and underlying EventPipe) unnecessarily in such cases.ReusableSink
capturesweak
when vending to the 'outside world'Checklist