Skip to content

fix: prevent listener accumulation via shared onceExclusive() base class#68

Merged
stoprocent merged 1 commit into
mainfrom
claude/fix-noble-issue-61-vm38r
Feb 20, 2026
Merged

fix: prevent listener accumulation via shared onceExclusive() base class#68
stoprocent merged 1 commit into
mainfrom
claude/fix-noble-issue-61-vm38r

Conversation

@stoprocent
Copy link
Copy Markdown
Owner

Introduce NobleEventEmitter, a thin EventEmitter subclass with a single onceExclusive(event, callback) method that ensures at most one listener per event name. Previous listener is removed before adding a new one, preventing accumulation when methods are called repeatedly before the event fires.

All classes (Noble, Peripheral, Characteristic, Service, Descriptor) now extend NobleEventEmitter and use onceExclusive() for callback-based methods: setScanParameters, startScanning, stopScanning, connect, disconnect, updateRssi, discoverServices, read/writeHandle, write, subscribe/unsubscribe, discoverDescriptors, broadcast, readValue, writeValue, discoverIncludedServices, discoverCharacteristics.

Also fixes cross-listener cleanup in discoverAsync() and notificationsAsync() using a shared cleanup guard pattern.

Closes #61

https://claude.ai/code/session_013EXDtBm4WGje3Jcbt4LBP9

Introduce NobleEventEmitter, a thin EventEmitter subclass with a single
onceExclusive(event, callback) method that ensures at most one listener
per event name. Previous listener is removed before adding a new one,
preventing accumulation when methods are called repeatedly before the
event fires.

All classes (Noble, Peripheral, Characteristic, Service, Descriptor) now
extend NobleEventEmitter and use onceExclusive() for callback-based
methods: setScanParameters, startScanning, stopScanning, connect,
disconnect, updateRssi, discoverServices, read/writeHandle, write,
subscribe/unsubscribe, discoverDescriptors, broadcast, readValue,
writeValue, discoverIncludedServices, discoverCharacteristics.

Also fixes cross-listener cleanup in discoverAsync() and
notificationsAsync() using a shared cleanup guard pattern.

Closes #61

https://claude.ai/code/session_013EXDtBm4WGje3Jcbt4LBP9
@stoprocent stoprocent merged commit 013a09f into main Feb 20, 2026
28 of 29 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.3.16 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"terminate called without an active exception" C++ crash

2 participants