Skip to content

Fix DeviceDetectorCache cache eviction flakiness#84

Draft
tzi wants to merge 1 commit into5.x-devfrom
fix-devicedetectorcache-flaky-test
Draft

Fix DeviceDetectorCache cache eviction flakiness#84
tzi wants to merge 1 commit into5.x-devfrom
fix-devicedetectorcache-flaky-test

Conversation

@tzi
Copy link

@tzi tzi commented Mar 11, 2026

Description

This PR fixes flaky cache eviction behavior in the DeviceDetectorCache plugin.

When cached device detector entries are reused, their access time is now refreshed before eviction decisions are made. This makes cache cleanup behave like an LRU-style policy and prevents recently used cache files from being deleted unexpectedly.

Changes

  • Refresh cache file access time when a cached entry is loaded.
  • Keep deleteLeastAccessedFiles() based on access time, but make the recorded access time meaningful by updating it on reads.
  • Update the integration test to reflect the correct entry that should remain after the second warm-cache run.

Why

WarmDeviceDetectorCacheTest::testDoesClearExistingFilesFromCacheByDefaultWhenTooManyEntriesExist was flaky because reading a cached entry did not update its file access time. As a result, cleanup could delete an entry that had just been reused.

Testing

  • Updated WarmDeviceDetectorCacheTest to assert the recently accessed cache entry is preserved.
  • The new behavior matches the intended “delete least accessed files” logic.

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [✔] Are all newly added texts included via translation?
  • [✔] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

@tzi tzi force-pushed the fix-devicedetectorcache-flaky-test branch from 2657892 to 760415b Compare March 12, 2026 09:27
@tzi tzi force-pushed the fix-devicedetectorcache-flaky-test branch from 760415b to ec9beb1 Compare March 12, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant