Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-dms-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/xmtp.chat": patch
---

fix: avoid reporting handled get_inbox_ids DM load errors
7 changes: 5 additions & 2 deletions apps/xmtp.chat/src/components/Conversation/LoadDM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router";
import { LoadingMessage } from "@/components/LoadingMessage";
import { useClient } from "@/contexts/XMTPContext";
import { isGetInboxIdsRequestError } from "@/helpers/errors";
import { isValidName, resolveNameQuery } from "@/helpers/names";
import { isValidEthereumAddress } from "@/helpers/strings";
import { useSettings } from "@/hooks/useSettings";
Expand Down Expand Up @@ -93,8 +94,10 @@ export const LoadDM: React.FC = () => {

navigateToHome("Error loading DM, redirecting...");

// rethrow error for error modal
throw e;
if (!isGetInboxIdsRequestError(e)) {
// rethrow unhandled errors for error modal
throw e;
}
}
};

Expand Down
19 changes: 19 additions & 0 deletions apps/xmtp.chat/src/helpers/errors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { isGetInboxIdsRequestError } from "./errors";

describe("isGetInboxIdsRequestError", () => {
it("detects get_inbox_ids request errors", () => {
expect(
isGetInboxIdsRequestError(
new Error(
'api client error api client at endpoint "get_inbox_ids" has error error sending request',
),
),
).toBe(true);
});

it("ignores other errors", () => {
expect(isGetInboxIdsRequestError(new Error("Wrong chain id"))).toBe(false);
expect(isGetInboxIdsRequestError("get_inbox_ids")).toBe(false);
});
});
11 changes: 11 additions & 0 deletions apps/xmtp.chat/src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ export class ClientNotFoundError extends Error {
super(`XMTP client is required when ${context}`);
}
}

export const isGetInboxIdsRequestError = (error: unknown) => {
if (!(error instanceof Error)) {
return false;
}

return (
error.message.includes('endpoint "get_inbox_ids"') &&
error.message.includes("error sending request")
);
};