Skip to content

fix(react-native): cancel prior iOS Combine sinks before re-subscribing (FR-25940) - #96

Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-ios-listener-leak
Closed

fix(react-native): cancel prior iOS Combine sinks before re-subscribing (FR-25940)#96
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-ios-listener-leak

Conversation

@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator

FR-25940 — iOS listener leak: subscribe() accumulates Combine sinks on every re-mount

Each FronteggWrapper mount calls listener()FronteggRN.subscribe(). subscribe() added two new sinks to cancellables on every call and never cancelled them — stopObserving() only flips hasListeners. So N remounts meant N× duplicate native event work per state change, masked only by the 50 ms JS debounce. Android already disposes the prior subscription before re-subscribing.

Fix

Cancel and clear cancellables at the start of subscribe(), mirroring Android's dispose-before-subscribe.

Note

iOS-only; verified via swiftc -parse. Not compiled in a full iOS build here (no iOS build harness) — please let CI confirm.

…ng (FR-25940)

Each FronteggWrapper mount calls listener() -> FronteggRN.subscribe(), which added two Combine
sinks to cancellables on every call and never cancelled them (stopObserving only flips a flag).
N remounts meant N x duplicate native event work per state change, masked only by the 50 ms JS
debounce. Cancel and clear cancellables at the start of subscribe(), mirroring Android which
disposes the prior subscription before re-subscribing.
@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator Author

Superseded by #100, which combines FR-25937/38/39/40 into a single PR. Branch kept.

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.

1 participant