Skip to content

Listeners are not removed upon unsubscribe() #288

@Faibk

Description

@Faibk

If topic.unsubscribe() is called without a parameter, it will not remove the callbacks, but instead unregister the whole topic at the rosconnection. This is fine as long as the topic object is destroyed after unsubscribing, but in my use case we subscribe to the same topic instance again. This adds a new callback and re-registers at the ros connection, which means now two callbacks are executed...

The problem seems to be acknowledged in this code comment:

// Note: Don't call this.removeAllListeners, allow client to handle that themselves

I do not see why the client would want to handle this itself, as it seems to be the expected outcome. unsubscribe(X) removes callback X from the topic's listener-list so the paradigm seems to be "unsubscribe X from the topic`. This should be the same without parameters, but currently it is "unsubscribe the topic from ros", which changes the direction of the method.

I propose not only unsubscribing to ros, but also removing all listener callbacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions