Skip to content

fix: keep bind subscription cleanup idempotent - #363

Merged
liuliu-dev merged 1 commit into
github:mainfrom
feritcemkahraman:fix/idempotent-bind-unsubscribe
Oct 19, 2026
Merged

liuliu-dev merged 1 commit into
github:mainfrom
feritcemkahraman:fix/idempotent-bind-unsubscribe

Conversation

@feritcemkahraman

Copy link
Copy Markdown
Contributor

Calling an old listenForBind(root) subscription's unsubscribe() again after subscribing to the same root removes the new subscription from the cache. Another call then creates a second observer; closing the returned subscription can leave the original observer binding new actions.

Return early when the subscription is already closed, so cleanup stays idempotent. Added tests for reusing the current subscription and for stopping action binding after cleanup.

Validation: both regressions failed before the fix; all 131 Chromium tests pass afterward. Full ESLint, TypeScript, package build and both bundle-size limits pass. Firefox and WebKit were not run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused guard fixes stale-subscription cleanup, and regression tests cover both reported failure modes.

No open issues 🎉

What changed in this PR

Makes binding-subscription cleanup idempotent so repeated cleanup cannot invalidate a newer subscription.

Changes:

  • Returns early when a subscription is already closed.
  • Adds regressions for cached subscription reuse and stopping action binding after cleanup.
File Description
test/​bind.ts Tests subscription reuse and observer cleanup.
src/​bind.ts Guards against repeated unsubscription.

Review effort: Max

@liuliu-dev
liuliu-dev merged commit e1c3fa3 into github:main Oct 19, 2026
3 checks passed
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