fix(app): avoid unsupported Android array sorting (#3241)

Hermes in the production Android app does not provide Array.prototype.toSorted. Multi-host project selection and provider cache eviction could therefore crash when they reached deterministic sorting paths.
This commit is contained in:
Mohamed Boudra
2026-08-12 00:23:22 +02:00
committed by GitHub
parent 23d7a8eaf9
commit 5f5c585e68
3 changed files with 29 additions and 3 deletions
@@ -136,7 +136,7 @@ export function createProviderSnapshotCache(
}
let totalBytes = entries.reduce((total, entry) => total + entry.bytes, 0);
const retainedEntries = entries.toSorted(oldestFirst);
const retainedEntries = [...entries].sort(oldestFirst);
while (totalBytes > maxBytes) {
const evicted = retainedEntries.shift();
if (!evicted) break;
@@ -186,7 +186,7 @@ export function createProviderSnapshotCache(
if (canStoreIncoming) projectedBytes += incomingBytes;
const keysToRemove: string[] = [];
for (const candidate of retainedEntries.toSorted(oldestFirst)) {
for (const candidate of [...retainedEntries].sort(oldestFirst)) {
if (projectedBytes <= maxBytes) break;
projectedBytes -= candidate.bytes;
keysToRemove.push(candidate.key);