• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RobotWebTools / rclnodejs / 45930647846
91%

Build:
DEFAULT BRANCH: develop
Ran 27 Nov 2026 02:55AM UTC
Jobs 1
Files 68
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

27 Nov 2026 02:50AM UTC coverage: 91.358% (+0.003%) from 91.355%
45930647846

push

github

web-flow
fix(observable_subscription): destroy native ROS subscription on destroy() (#1704)

## Problem

`ObservableSubscription.destroy()` / `.complete()` only calls `Subject.complete()`. It never destroys the underlying native ROS 2 subscription created in `Node.createObservableSubscription()`.

Any consumer that creates a **new** `ObservableSubscription` per reconnect and disposes of the previous one — for example a `switchMap` + `share()` wrapper whose `finalize()` calls `obsSub.destroy()`, driven by an RxJS `timeout()` + `catchError()` + `repeat()` pattern that detects a stalled topic — leaks one native subscription per reconnect cycle. Each leaked subscription keeps receiving and deserializing every message on the topic forever, with nothing listening to it. CPU usage climbs a little more on every reconnect and never comes back down.

Note: merely unsubscribing from RxJS (e.g. `repeat()` resubscribing to the *same* wrapper's `.observable`) never touches the native subscription either way — only an explicit `destroy()`/`complete()` call does. The leak only shows up once app code creates a fresh `ObservableSubscription` per cycle and relies on `destroy()` to free the old one, which is the pattern below.

## Fix

Pass the owning `Node` into `ObservableSubscription` and call `node.destroySubscription(subscription)` from `complete()`/`destroy()`, in addition to completing the `Subject`. `destroySubscription` is already idempotent (guarded by the entity's `isDestroyed()`), so this is safe to call even if the node itself destroys the subscription later (e.g. via `node.destroy()`).

## Reproduction

Minimal repro extracted from a real app that hit this (unrelated app internals mocked out). The `switchMap`/`share`/`finalize` wrapper is the part that actually creates a new `ObservableSubscription` on every reconnect and disposes of the previous one — this is what was missing from an earlier version of this repro:

```js
import rclnodejs from 'rclnodejs';
import { ... (continued)

2402 of 2803 branches covered (85.69%)

Branch coverage included in aggregate %.

9 of 9 new or added lines in 2 files covered. (100.0%)

18254 of 19807 relevant lines covered (92.16%)

310.88 hits per line

Jobs
ID Job ID Ran Files Coverage
1 45930647846.1 27 Nov 2026 02:55AM UTC 68
91.36
GitHub Action Run
Source Files on build 45930647846
  • Tree
  • List 68
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #45930647846
  • 5fbe5d19 on github
  • Prev Build on develop (#45775775444)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc