Skip to content

Fix disposal of pending account subscriptions - #171

Merged
ndisidore merged 1 commit into
mainfrom
fix/dispose-pending-account-subscriptions
Aug 12, 2026
Merged

Fix disposal of pending account subscriptions#171
ndisidore merged 1 commit into
mainfrom
fix/dispose-pending-account-subscriptions

Conversation

@ndisidore

Copy link
Copy Markdown
Contributor

Previously, effect cleanup waited for the subscription RPC to resolve before disposing its stub. If the component unmounted while that RPC was still pending, the pending subscription could remain undisposed and leak server-side resources.

Cap’n Web RPC promises are themselves disposable, so this change disposes the pending promise directly during cleanup. This handles both pending and resolved subscriptions correctly.

@github-actions github-actions Bot added the workshop/frontend Changes to the Workshop frontend label Aug 12, 2026
@ask-bonk

ask-bonk Bot commented Aug 12, 2026

Copy link
Copy Markdown

gatekeepers.tsx correctly removed the useRef import (no longer used), while GatekeeperModal.tsx keeps it because other refs remain. The import cleanup is correct — this matters since unused imports are lint errors in this repo.

The PR is clean and correct:

  • The core fix is sound: Cap'n Web RPC promises are disposable, so disposing the promise directly handles both the pending and resolved cases, closing the leak where a component unmounts before subscribeConnectedAccounts resolves.
  • The refactor is applied consistently across all six subscription sites, removing the now-unnecessary refs/local stub variables and the useRef import where it became unused.
  • ObserverConfigModal.tsx correctly gains if (cancelled) return guards in its subscriber callbacks — previously the cancellation check only lived in the resolved .then, so with synchronous disposal those guards are needed to avoid setState-after-unmount. The other files already had equivalent guards.
  • The new test properly exercises the pending-subscription path with a never-resolving promise carrying a [Symbol.dispose], and the fakeApi update to return a disposable resolved promise keeps existing tests accurate.

LGTM!

github run

@ndisidore
ndisidore merged commit 0f168f4 into main Aug 12, 2026
8 checks passed
@ndisidore
ndisidore deleted the fix/dispose-pending-account-subscriptions branch August 12, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

workshop/frontend Changes to the Workshop frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant