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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user