Skip to content
Merged
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/short-mice-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes rooms failing to open on transient network errors, and prevents a "Room Not Found" flash when opening a room with a local subscription
17 changes: 16 additions & 1 deletion apps/meteor/client/views/room/hooks/useOpenRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export function useOpenRoom({ type, reference }: { type: RoomType; reference: st
try {
roomData = await getRoomByTypeAndName(type, reference);
} catch (error) {
const isDefinitivelyNotFound = error && typeof error === 'object' && 'error' in error && error.error === 'error-invalid-room';

if (!isDefinitivelyNotFound) {
throw error;
}

if (type !== 'd') {
throw new RoomNotFoundError(undefined, { type, reference });
}
Expand Down Expand Up @@ -137,7 +143,16 @@ export function useOpenRoom({ type, reference }: { type: RoomType; reference: st

return { rid: room._id };
},
retry: 0,
retry: (failureCount, error) => {
const unrecoverableErrors = [RoomNotFoundError, OldUrlRoomError, NotAuthorizedError, NotSubscribedToRoomError];

if (unrecoverableErrors.some((e) => error instanceof e)) {
return false;
}

return failureCount < 4;
},
retryDelay: (attempt) => Math.min(1000 * 2 ** attempt, 5000),
});

const queryClient = useQueryClient();
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/room/providers/RoomProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const RoomProvider = ({ rid, children }: RoomProviderProps) => {
}, [rid, subscribed]);

if (!pseudoRoom) {
return !room ? <RoomNotFound /> : <RoomSkeleton />;
return !room && !subscritionFromLocal ? <RoomNotFound /> : <RoomSkeleton />;
}

return (
Expand Down
Loading