Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener callback is invoked multiple times when message is published and when calling subscribe multiple times #230

Closed
puopg opened this issue Nov 22, 2021 · 7 comments · Fixed by #232
Labels
status: done This issue is considered resolved.

Comments

@puopg
Copy link

puopg commented Nov 22, 2021

Edit: Changed the title to be more representative of the bug at hand.

Seeing some interesting behavior differences after upgrading to version 4.34.0.

Services currently enabled on my key:

  • Storage and playback
  • Stream controller
  • Access Manager

Context here is a simple chat application. On message publish, a client receives that message via subscribing to the channel. However, a special situation here is we are subscribed to a channel group.

  • Upon first publish, the client correctly hears a single event, and the handler is called once.
    • Also push a signal to the subscribed channel group. Observe still the handler is called once. (We have attached a channel for this signal onto the channel group).
  • Publish a 2nd message now, and also publish another signal to the subscribed channel group.
  • Observe that the handler is called multiple times.
    • I've seen a varying amount of invocations, sometimes its 4 calls to the handler, sometimes 3, sometimes its just 1.

Affected version: 4.34.0
Unaffected version: 4.33.1

Actual outcome:
Multiple invocations to the handler.

Expected outcome:
A single invocation to the handler.

@puopg puopg changed the title Message handler on listener object is invoked multiple times when a single message is published when subscribed to channel group Message handler on listener object is invoked multiple times when a single message is published when subscribed to channel group receives an event Nov 22, 2021
@samuellawerentz
Copy link

I'm having the similar issue where the handler is invoked multiple times.
v4.33.0 is working fine.
After updating to v4.34.1 its firing multiple times.

For one message, the handler is firing 4 to 5 times depending on the number of times the pubnub.subscribe() method was called.

@puopg
Copy link
Author

puopg commented Nov 30, 2021

I have attached 2 videos, one on 4.33.1 the other using 4.34.0.

Code sandbox also attached. This is a simple counter to visually see how many times the handler is invoked. Notice I only call addListener once, and the only change is calling subscribe.

Codesandbox: https://codesandbox.io/s/dazzling-cannon-y71vi

4.33.1

Screen.Recording.2021-11-30.at.10.14.07.AM.mov

4.34.0

Screen.Recording.2021-11-30.at.10.14.45.AM.mov

@puopg
Copy link
Author

puopg commented Nov 30, 2021

@raipubnub Have you guys noticed this?

@puopg puopg changed the title Message handler on listener object is invoked multiple times when a single message is published when subscribed to channel group receives an event Listener callback is invoked multiple times when message is published and when calling subscribe multiple times Nov 30, 2021
@ghost
Copy link

ghost commented Dec 1, 2021

Thanks for the detailed report @puopg. We are looking at this and will provide an update once we finish the analysis.

@ghost
Copy link

ghost commented Dec 1, 2021

This was a result of a change in superagent that affected chaining the end method. We have a fix ready to go out, should be released soon.

@ghost ghost closed this as completed in #232 Dec 1, 2021
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

@puopg this issue is addressed in v4.34.2

@github-actions github-actions bot added the status: done This issue is considered resolved. label Dec 1, 2021
@puopg
Copy link
Author

puopg commented Dec 4, 2021

Cool thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: done This issue is considered resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants