-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Microsoft Teams - Stop triggers from unnecessarily emitting every event every run #18632
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
WalkthroughAdjusted handling of lastCreated in components/microsoft_teams/sources/common/base.mjs: initial assignment now uses _getLastCreated() directly instead of Date.parse, while subsequent updates still use Date.parse(createdDateTime). getResources continues to receive lastCreated; persistence stores lastCreated after loop. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
WHY
On line 65, the value saved with
_setLastCreated
is already parsed as a unix timestamp. Thus when getting the value, there's no reason to callDate.parse
again. It's already in the correct format.In fact, this actually breaks it and returns NaN. This then causes every event to be emitted unnecessarily. I believe the only reason this still actually works is because of the
dedupe: "unique"
, but that's just a guess - I'm not too sure.Important Note
There is a larger issue at play here (new issue) where every resource is paginated through every time a trigger is run. For the New Chat Message trigger, this causes storage/memory issues for significantly sized chats:
It makes sense to paginate through every resource for some of the triggers which have no intrinsic ordering, like get channels, but for triggers that have an order by created date, like get channel/chat messages, this makes no sense. Only the events since the last checked time need to be fetched from the api, so there's no point in paginating through every possible resource.
Summary by CodeRabbit