diff --git a/apps/web/src/components/structures/RoomSearchView.tsx b/apps/web/src/components/structures/RoomSearchView.tsx
index bfd800e7d9..8892b197a3 100644
--- a/apps/web/src/components/structures/RoomSearchView.tsx
+++ b/apps/web/src/components/structures/RoomSearchView.tsx
@@ -119,6 +119,14 @@ export const RoomSearchView = ({ term, scope, promise, className, onUpdate, inPr
logger.error("Discarding stale search results");
return false;
}
+ if (error?.name === "AbortError") {
+ // Opening a result aborts the search, which rejects whatever request is
+ // still in flight. We asked for that, so there is nothing to tell the user
+ // about — and the rejection can reach us before the unmount which would
+ // otherwise have set `aborted`.
+ debuglog("search aborted");
+ return false;
+ }
logger.error("Search failed", error);
onUpdate(false, null, error);
return false;
diff --git a/apps/web/test/unit-tests/components/structures/RoomSearchView-test.tsx b/apps/web/test/unit-tests/components/structures/RoomSearchView-test.tsx
index dccf608003..b9dbe9841c 100644
--- a/apps/web/test/unit-tests/components/structures/RoomSearchView-test.tsx
+++ b/apps/web/test/unit-tests/components/structures/RoomSearchView-test.tsx
@@ -330,6 +330,33 @@ describe("", () => {
expect(onUpdate).toHaveBeenCalledTimes(2);
});
+ it("does not report an aborted search as an error", async () => {
+ const onUpdate = jest.fn();
+ const deferred = Promise.withResolvers();
+
+ render(
+
+
+ ,
+ );
+ // What fetch rejects with when RoomView aborts the search to open one of its results.
+ deferred.reject(new DOMException("signal is aborted without reason", "AbortError"));
+ try {
+ // Wait for RoomSearchView to process the promise
+ await deferred.promise;
+ } catch {}
+
+ expect(onUpdate).toHaveBeenCalledTimes(1);
+ expect(onUpdate).toHaveBeenCalledWith(true, null, null);
+ });
+
it("should combine search results when the query is present in multiple sucessive messages", async () => {
const searchResults: ISearchResults = {
results: [