fix: suppress unhandled promise rejections from fire-and-forget useEffect loads
CI / Build & Quality Checks (push) Successful in 10m56s
CI / Build & Quality Checks (push) Successful in 10m56s
useAsync re-throws errors after storing them in state — correct for awaited callers but causes unhandled rejections when load() is called without .catch() in useEffects. The error is already captured in AsyncState.Error so the re-throw provides no additional value in these fire-and-forget patterns. Fixes JAVASCRIPT-REACT-M (Sentry: Media download failed: 401 Unauthorized) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ export function ClientConfigLoader({ fallback, error, children }: ClientConfigLo
|
|||||||
const ignoreCallback = useCallback(() => setIgnoreError(true), []);
|
const ignoreCallback = useCallback(() => setIgnoreError(true), []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
load();
|
void load().catch(() => undefined);
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
if (state.status === AsyncStatus.Idle || state.status === AsyncStatus.Loading) {
|
if (state.status === AsyncStatus.Idle || state.status === AsyncStatus.Loading) {
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (autoPlay) loadSrc();
|
if (autoPlay) void loadSrc().catch(() => undefined);
|
||||||
}, [autoPlay, loadSrc]);
|
}, [autoPlay, loadSrc]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export function ThumbnailContent({ info, renderImage }: ThumbnailContentProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadThumbSrc();
|
void loadThumbSrc().catch(() => undefined);
|
||||||
}, [loadThumbSrc]);
|
}, [loadThumbSrc]);
|
||||||
|
|
||||||
return thumbSrcState.status === AsyncStatus.Success ? renderImage(thumbSrcState.data) : null;
|
return thumbSrcState.status === AsyncStatus.Success ? renderImage(thumbSrcState.data) : null;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (autoPlay) loadSrc();
|
if (autoPlay) void loadSrc().catch(() => undefined);
|
||||||
}, [autoPlay, loadSrc]);
|
}, [autoPlay, loadSrc]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export function EditHistoryModal({ room, mEvent, onClose }: EditHistoryModalProp
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchHistory();
|
void fetchHistory().catch(() => undefined);
|
||||||
}, [fetchHistory]);
|
}, [fetchHistory]);
|
||||||
|
|
||||||
const formatTs = (ts: number): string => {
|
const formatTs = (ts: number): string => {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export const useAsyncCallbackValue = <TData, TError>(
|
|||||||
const [state, load] = useAsyncCallback<TData, TError, []>(asyncCallback);
|
const [state, load] = useAsyncCallback<TData, TError, []>(asyncCallback);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
load();
|
void load().catch(() => undefined);
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
return [state, load];
|
return [state, load];
|
||||||
|
|||||||
Reference in New Issue
Block a user