# Identify last subscriber for a branch

**URL:** <https://community.interop.io/t/identify-last-subscriber-for-a-branch/351>\
**Category:** io.Connect Desktop\
**Created:** [November 11, 2025, 3:46pm UTC](https://community.interop.io/t/identify-last-subscriber-for-a-branch/351 "2025-11-11T15:46:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous1](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/anonymous1/32/54_2.png) [@anonymous1](https://community.interop.io/u/anonymous1)\
**Post date:** [November 11, 2025, 3:46pm UTC](https://community.interop.io/t/identify-last-subscriber-for-a-branch/351/1 "2025-11-11T15:46:50Z")

</div>

### Product, Libraries & Version

IOCD 9.7

### Goal

I’m looking for a way to detect when the last subscriber for a specific branch is gone and no one is listening to that branch anymore.

Is the simplest way to keep a count of subscribers?

---

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [November 12, 2025, 10:15am UTC](https://community.interop.io/t/identify-last-subscriber-for-a-branch/351/2 "2025-11-12T10:15:46Z")

</div>

When handling the `subscriptionRemoved` event, check if `streamSubscription.stream.branch(key)` returns `undefined`.  
If it does, that means there are no more subscribers left on that branch. Something like:

```auto
function onSubscriptionRemoved(streamSubscription) {
  const key = streamSubscription.arguments.symbol;
  const branch = streamSubscription.stream.branch(key);   
  if (branch === undefined) { // last sub is gone
    //console.warn(`Branch is gone".`);
  }

```
