fix: hold broadcaster until deinit finishes#90
Conversation
| } | ||
| let broadcaster = self.broadcaster | ||
| Task { | ||
| await broadcaster.finish() |
There was a problem hiding this comment.
should be, isn't ?
guard let self else { return }
await broadcaster.finish()
There was a problem hiding this comment.
No, Task is not member of class. You need that if task is part of class.
There was a problem hiding this comment.
you'll need to capture self in the capture list
There was a problem hiding this comment.
Task { [weak self] in
guard let self else { return }
....
There was a problem hiding this comment.
You shouldn't do anything with self here
| for await event in stream { | ||
| #expect(event == .didBecomeActive) | ||
| streamFinished = true | ||
| } |
There was a problem hiding this comment.
Bug: Test incorrectly sets streamFinished inside loop, not after
The streamFinished flag is set inside the for await loop when an event is received, but the test comment claims it verifies "the stream should be finished." The flag is set to true upon receiving any event, not when the stream actually terminates (which happens after the loop exits). This means the test could pass when receiving an event even if the stream never properly finishes via broadcaster.finish(). The assignment streamFinished = true needs to be placed after the for await loop to correctly verify stream termination.
🤖 I have created a release *beep* *boop* --- ## [0.12.1](0.12.0...0.12.1) (2025-12-09) ### Bug Fixes * hold broadcaster until deinit finishes ([#90](#90)) ([8a00733](8a00733)) * Remove double image workaround for RRWeb ([#92](#92)) ([4faede4](4faede4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Bumps to 0.12.1 and updates the changelog with two bug fixes; aligns podspecs and sdkVersion. > > - **Release/Versioning**: > - Bump version to `0.12.1` in `.release-please-manifest.json`, `LaunchDarklyObservability.podspec`, `LaunchDarklySessionReplay.podspec`, and `Sources/LaunchDarklyObservability/Version.swift` (`sdkVersion`). > - **Changelog**: > - Add `0.12.1` notes with bug fixes: hold broadcaster until deinit finishes; remove double image workaround for RRWeb. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 921b6f7. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
After deinit all members are gone. We need hold broadcaster until deinit finishes
Note
Retains the broadcaster during deinit to ensure the event stream finishes, exposes
sendfor testing, and adds a memory test validating deallocation and stream completion.AppLifecycleManager: retainbroadcasterindeinitbefore finishing to ensure stream completion.send(_:)non-private to allow external triggering (used by tests).Tests/ObservabilityTests/Session/AppLifecycleManagerMemoryTests.swiftverifying manager deallocation and stream finishing with an active subscription.Written by Cursor Bugbot for commit 185a7df. This will update automatically on new commits. Configure here.