Closed
Description
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.
❯ node --version
v14.19.0
OS: MAC OS
Describe the bug
TeamsActivityHandler, when an activity is received, calls each handler added by onEvent(handler)
twice
To Reproduce
- Self explanatory, add an event, call it
Expected behavior
Event handlers should be called once
Activity
Prevent calling event handlers twice
[botbuilder] TeamsActivityHandler — Prevent calling event handlers twice
[botbuilder] TeamsActivityHandler — Prevent calling event handlers twice
alexrecuenco commentedon Apr 25, 2022
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
iKnowRam commentedon Apr 26, 2022
Hey @alexrecuenco,
I'm able to reproduce. I ran the /teamsActivityHandler.test.js / unit test in current main branch and the
onEvent
method is being called twice.botbuilder-js/libraries/botbuilder/tests/teamsActivityHandler.test.js
Line 2311 in dcf434d
Screenshot:

iKnowRam commentedon Apr 26, 2022
I'm not sure if this is by design or a bug within the JS SDK.
I will discuss this with the SDK engineering team today.
iKnowRam commentedon Apr 27, 2022
Update:
I attempted to repro on the .NET SDK, and it looks like the
OnEventActivityAsync
method forTeamsActivityHandler
is called once.Here are the steps I took:
Cloned and built the botbuilder-dotnet repo on my local machine environment
Navigate to /TeamsActivityHandlerTests.cs / test file
In TestActivityHandler class, I created getter and setter property set to 0 by default, to count the number of calls for
OnEventActivityAsyn
private class TestActivityHandler : TeamsActivityHandler { + public int NumberOfOnEventCalls { get; set; } = 0; public List<string> Record { get; } = new List<string>();
Then, in OnEventActivityAsync method, I increment the
NumberOfOnEventCalls
property by one if it gets called.protected override Task OnEventActivityAsync(ITurnContext<IEventActivity> turnContext, CancellationToken cancellationToken) { Record.Add(MethodBase.GetCurrentMethod().Name); + NumberOfOnEventCalls++; return base.OnEventActivityAsync(turnContext, cancellationToken); }
Ran the TestOnEventActivity() test case, and debugged the
NumberOfOnEventCalls
property. It seems it was only called once.Also, I created a temporary branch of my changes here microsoft/botbuilder-dotnet@1d18e1f
alexrecuenco commentedon Apr 27, 2022
Thank you for your effort verifying the inconsistency. I hope #4203 is a sufficient solution.
8 remaining items