fix(mobile): prevent Android thread search crash (#5386)

This commit is contained in:
shivam authored and GitHub committed 2026-08-05 11:30:10 +05:30
1 parent 47dfc65265
commit 70de6e1786
2 files changed
+14 -1

No files matched your search

@@ -23,6 +23,19 @@ it("creates stable keys regardless of environment order", () => {
);
});
it("creates keys without array methods unavailable in Hermes", () => {
const descriptor = Object.getOwnPropertyDescriptor(Array.prototype, "toSorted");
Reflect.deleteProperty(Array.prototype, "toSorted");
try {
expect(makeThreadSearchKey([envB, envA], "needle")).toBe('[["env-a","env-b"],"needle"]');
} finally {
if (descriptor !== undefined) {
Reflect.defineProperty(Array.prototype, "toSorted", descriptor);
}
}
});
it("encodes scoped thread keys without delimiter collisions", () => {
const first = threadSearchMatchKey({
environmentId: EnvironmentId.make("env\u0000thread"),
@@ -28,7 +28,7 @@ export function makeThreadSearchKey(
query: string,
): string {
return JSON.stringify([
[...environmentIds].toSorted((left, right) => left.localeCompare(right)),
[...environmentIds].sort((left, right) => left.localeCompare(right)),
query,
]);
}