taiwangoldcard / taiwan-bot

🇹🇼 🤖
10 stars 5 forks source link

Bot crashes if you spam it too many times #34

Open matrinox opened 3 years ago

matrinox commented 3 years ago

I tested this by spamming taiwan a lot of times; it responded 17 times before it encountered a bug Unsure if this is crashes if one person spams it too much or if it hits a certain threshold of requests from all sources. Here's "proof":

Screen Shot 2020-11-05 at 12 03 28 AM Screen Shot 2020-11-05 at 12 03 37 AM
matrinox commented 3 years ago

@erickhun @geekyme ~Do we have some way to monitor errors? Maybe I could have a look at it to debug it. Otherwise, I could investigate into adding one~ I see @geekyme already implanted tracing. Where do we see the traces?

matrinox commented 3 years ago

When I played around with it locally, I noticed I reached quota limits with google sheets. Perhaps that is the problem? Might be worth checking. Here are my logs (note that line numbers may not line up with yours cause I'm on a different branch than master):

Traceback (most recent call last):
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/botbuilder/core/bot_adapter.py", line 127, in run_pipeline
    return await self._middleware.receive_activity_with_status(
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
  File "./bots/faq_bot.py", line 122, in on_turn
    await super().on_turn(turn_context)
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/botbuilder/core/activity_handler.py", line 68, in on_turn
    await self.on_message_activity(turn_context)
  File "./bots/faq_bot.py", line 89, in on_message_activity
    self.bot_sheet.log_answers(
  File "./taiwan_bot_sheet.py", line 67, in log_answers
    sheet.update( 'A' + str(next_row) , datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/gspread/utils.py", line 592, in wrapper
    return f(*args, **kwargs)
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/gspread/models.py", line 1096, in update
    response = self.spreadsheet.values_update(
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/gspread/models.py", line 235, in values_update
    r = self.client.request('put', url, params=params, json=body)
  File "~/taiwan-bot/.venv/lib/python3.8/site-packages/gspread/client.py", line 73, in request
    raise APIError(response)
gspread.exceptions.APIError: {'code': 429, 'message': "Quota exceeded for quota group 'WriteGroup' and limit 'Write requests per user per 100 seconds' of service 'sheets.googleapis.com' for consumer 'project_number:#############'.", 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developer console API key', 'url': 'https://console.developers.google.com/project/#############'/apiui/credential'}]}]}