#1317 Fixed priority of events isolation (#1318)

This commit is contained in:
Alex Root Junior 2023-09-21 22:54:48 +03:00 committed by GitHub
parent 8a77939d5b
commit a0828f6ddf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 1 deletions

View file

@ -34,8 +34,10 @@ class FSMContextMiddleware(BaseMiddleware):
context = self.resolve_event_context(bot, data)
data["fsm_storage"] = self.storage
if context:
data.update({"state": context, "raw_state": await context.get_state()})
# Bugfix: https://github.com/aiogram/aiogram/issues/1317
# State should be loaded after lock is acquired
async with self.events_isolation.lock(key=context.key):
data.update({"state": context, "raw_state": await context.get_state()})
return await handler(event, data)
return await handler(event, data)