Skip to content

Commit 371c30a

Browse files
shivamhwpcursoragent
authored andcommitted
fix(mobile): prevent Android thread search crash (pingdotgg#5386)
1 parent d26bfbf commit 371c30a

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/client-runtime/src/state/threadSearch.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ it("creates stable keys regardless of environment order", () => {
2323
);
2424
});
2525

26+
it("creates keys without array methods unavailable in Hermes", () => {
27+
const descriptor = Object.getOwnPropertyDescriptor(Array.prototype, "toSorted");
28+
Reflect.deleteProperty(Array.prototype, "toSorted");
29+
30+
try {
31+
expect(makeThreadSearchKey([envB, envA], "needle")).toBe('[["env-a","env-b"],"needle"]');
32+
} finally {
33+
if (descriptor !== undefined) {
34+
Reflect.defineProperty(Array.prototype, "toSorted", descriptor);
35+
}
36+
}
37+
});
38+
2639
it("encodes scoped thread keys without delimiter collisions", () => {
2740
const first = threadSearchMatchKey({
2841
environmentId: EnvironmentId.make("env\u0000thread"),

packages/client-runtime/src/state/threadSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function makeThreadSearchKey(
2828
query: string,
2929
): string {
3030
return JSON.stringify([
31-
[...environmentIds].toSorted((left, right) => left.localeCompare(right)),
31+
[...environmentIds].sort((left, right) => left.localeCompare(right)),
3232
query,
3333
]);
3434
}

0 commit comments

Comments
 (0)