Using the `@frappe.whitelist(allow_guest=True)` decorator leads to automatic logout

For the past 5 days, I have been experiencing an issue like this. When I log in through API or portal, I automatically get logged out when accessing an endpoint that has the parameter allow_guest=True. Why does this happen?