1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-27 13:49:10 +02:00

fix: flaky delete stale session (#10387)

When deleting stale sessions, we sort them by createdAt. If both
sessions are created with the same createdAt, there's a chance we get a
different sort order and we end up with the wrong order:
https://github.com/Unleash/unleash/actions/runs/16438565746/job/46453700977

I think adding 10ms between inserts should be enough (1ms should do,
but this gives me more confidence and doesn't hurt that much)

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
This commit is contained in:
Gastón Fournier 2025-07-22 13:42:14 +02:00 committed by GitHub
parent dc81f81b54
commit e140ab63e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,6 +114,7 @@ test('Can delete session by sid', async () => {
test('Can delete stale sessions', async () => {
await sessionService.insertSession(newSession);
await new Promise((resolve) => setTimeout(resolve, 10)); // Ensure a different createdAt
await sessionService.insertSession({ ...newSession, sid: 'new' });
const sessionsToKeep = 1;