-
Notifications
You must be signed in to change notification settings - Fork 279
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
[botbuilder]TeamsActivityHandler — Events are called twice #4202
Comments
Fixes microsoft#4202 - teamsActivityHandler overwrites `dispatchEventActivity` - `dispatchEventActivity` is only called from within `onEventActivity` - `onEventActivity` already calls all handlers - on teamsActivityHandler, when overwriting, previously it was calling the array of handlers again before dispatching A test is added to prevent the behavior from reappearing Note that to test the behavior issue, it is enough to apply the test without the change to code to main. The test fails in that case (since it is called twice)
Fixes microsoft#4202 Description This change prevents calling TeamsActivityHandler event handlers twice for every event received. Specific Changes - teamsActivityHandler overwrites `dispatchEventActivity` - `dispatchEventActivity` is only called from within `onEventActivity` - `onEventActivity` already calls all handlers - on teamsActivityHandler, when overwriting, previously it was calling the array of handlers again before dispatching Testing A test is added to prevent the behavior from reappearing Note that to test the issue described, it is enough to run the changed test in main. The test will fail when run in main currently, since since it is called twice.
Fixes microsoft#4202 Description This change prevents calling TeamsActivityHandler event handlers twice for every event received. Specific Changes Why were the event handlers getting called twice? - teamsActivityHandler overwrites `dispatchEventActivity` - `dispatchEventActivity` is only called from within `onEventActivity` - `onEventActivity` already dispatches *after* calling all handlers - on teamsActivityHandler, when overwriting, it is also calling all handlers How to fix it? - Prevent the handler call inside the dispatchEventHandler - This should have no effect on any consumer, since they should already be consuming only from within a onEventActivity call. Testing A test is added to prevent the behavior from reappearing Note that to test the issue described, it is enough to run the changed test in main. The test will fail when run in main currently, since since it is called twice.
The best way to test this issue is to use the PR #4203 and remove the code change: The test included in that PR will fail without the change included in that PR |
Hey @alexrecuenco, I'm able to reproduce. I ran the /teamsActivityHandler.test.js / unit test in current main branch and the
|
I'm not sure if this is by design or a bug within the JS SDK. |
Update: I attempted to repro on the .NET SDK, and it looks like the Here are the steps I took:
Also, I created a temporary branch of my changes here microsoft/botbuilder-dotnet@1d18e1f |
Thank you for your effort verifying the inconsistency. I hope #4203 is a sufficient solution. |
Fixes microsoft#4202 Description This change prevents calling TeamsActivityHandler event handlers twice for every event received. Specific Changes Why were the event handlers getting called twice? - teamsActivityHandler overwrites `dispatchEventActivity` - `dispatchEventActivity` is only called from within `onEventActivity` - `onEventActivity` already dispatches *after* calling all handlers - on teamsActivityHandler, when overwriting, it is also calling all handlers How to fix it? - Prevent the handler call inside the dispatchEventHandler - This should have no effect on any consumer, since they should already be consuming only from within a onEventActivity call. Testing A test is added to prevent the behavior from reappearing Note that to test the issue described, it is enough to run the changed test in main. The test will fail when run in main currently, since since it is called twice.
… handlers twice (#4203) * [botbuilder] TeamsActivityHandler — Prevent calling event handlers twice Fixes #4202 Description This change prevents calling TeamsActivityHandler event handlers twice for every event received. Specific Changes Why were the event handlers getting called twice? - teamsActivityHandler overwrites `dispatchEventActivity` - `dispatchEventActivity` is only called from within `onEventActivity` - `onEventActivity` already dispatches *after* calling all handlers - on teamsActivityHandler, when overwriting, it is also calling all handlers How to fix it? - Prevent the handler call inside the dispatchEventHandler - This should have no effect on any consumer, since they should already be consuming only from within a onEventActivity call. Testing A test is added to prevent the behavior from reappearing Note that to test the issue described, it is enough to run the changed test in main. The test will fail when run in main currently, since since it is called twice. * onConversationUpdate also has a double event issue Per @johnataylor suggestions, it seems that the ConversationUpdate activity type had a similar issue to onEvent The tests and the code are adjusted accordingly to reflect this. Other event types were reviewed and it doesn't seem that they have a similar issue.
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Versions
Current main branch (commit 08b73c4)
What package version of the SDK are you using.
OS: MAC OS
Describe the bug
TeamsActivityHandler, when an activity is received, calls each handler added by
onEvent(handler)
twiceTo Reproduce
Expected behavior
Event handlers should be called once
The text was updated successfully, but these errors were encountered: