mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Make session cleanup best effort
This commit is contained in:
@@ -742,12 +742,23 @@ Http::shutdown()
|
||||
return;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < ($count - $sessionLimit); $i++) {
|
||||
$session = array_shift($sessions);
|
||||
$dbForProject->deleteDocument('sessions', $session->getId());
|
||||
}
|
||||
try {
|
||||
for ($i = 0; $i < ($count - $sessionLimit); $i++) {
|
||||
$session = array_shift($sessions);
|
||||
|
||||
$dbForProject->purgeCachedDocument('users', $userId);
|
||||
if (!$session instanceof Document) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('sessions', $session->getId());
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
// Session-limit cleanup is best-effort. Concurrent session creation can race with
|
||||
// older-session deletion, but that should not fail the request that just created a
|
||||
// valid session for the user.
|
||||
} finally {
|
||||
$dbForProject->purgeCachedDocument('users', $userId);
|
||||
}
|
||||
});
|
||||
|
||||
Http::shutdown()
|
||||
|
||||
Reference in New Issue
Block a user