Skip to content

fix: hold broadcaster until deinit finishes#90

Merged
abelonogov-ld merged 2 commits intomainfrom
andrey/app-lify-cycle
Dec 9, 2025
Merged

fix: hold broadcaster until deinit finishes#90
abelonogov-ld merged 2 commits intomainfrom
andrey/app-lify-cycle

Conversation

@abelonogov-ld
Copy link
Copy Markdown
Contributor

@abelonogov-ld abelonogov-ld commented Dec 9, 2025

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 send for testing, and adds a memory test validating deallocation and stream completion.

  • Session:
    • AppLifecycleManager: retain broadcaster in deinit before finishing to ensure stream completion.
    • Make send(_:) non-private to allow external triggering (used by tests).
  • Tests:
    • Add Tests/ObservabilityTests/Session/AppLifecycleManagerMemoryTests.swift verifying 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.

}
let broadcaster = self.broadcaster
Task {
await broadcaster.finish()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be, isn't ?
guard let self else { return }
await broadcaster.finish()

Copy link
Copy Markdown
Contributor Author

@abelonogov-ld abelonogov-ld Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Task is not member of class. You need that if task is part of class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to capture self in the capture list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task { [weak self] in
guard let self else { return }
....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't do anything with self here

@abelonogov-ld abelonogov-ld enabled auto-merge (squash) December 9, 2025 18:58
for await event in stream {
#expect(event == .didBecomeActive)
streamFinished = true
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

@abelonogov-ld abelonogov-ld merged commit 8a00733 into main Dec 9, 2025
5 checks passed
@abelonogov-ld abelonogov-ld deleted the andrey/app-lify-cycle branch December 9, 2025 19:01
abelonogov-ld pushed a commit that referenced this pull request Dec 9, 2025
🤖 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 -->
abelonogov-ld added a commit that referenced this pull request Dec 10, 2025
* main:
  fix: Remove double image workaround for RRWeb (#92)
  fix: hold broadcaster until deinit finishes (#90)
abelonogov-ld added a commit that referenced this pull request Dec 11, 2025
* main:
  chore: Objective-c recordLog  (#94)
  chore(main): release 0.12.1 (#91)
  fix: Remove double image workaround for RRWeb (#92)
  fix: hold broadcaster until deinit finishes (#90)

# Conflicts:
#	Tests/ObservabilityTests/Session/AppLifecycleManagerMemoryTests.swift
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.

3 participants