Skip to content

Commit 7cd2c1f

Browse files
authored
🤖 fix: resolve console errors for ORPC iterator and HelpIndicator ref (#985)
## Summary Fixes two console errors that appear during normal operation: ### 1. React ref warning for HelpIndicator ``` Warning: Function components cannot be given refs. Attempts to access this ref will fail. Check the render method of `Primitive.button.SlotClone`. ``` **Cause:** `HelpIndicator` was a plain function component used inside `TooltipTrigger` with `asChild`, which needs to forward refs. **Fix:** Converted to `React.forwardRef`. ### 2. ORPC Event Iterator Validation Failed ``` [WorkspaceStore] Error in onChat subscription for xxx: ORPCError: Event iterator validation failed Caused by: ErrorEvent: An error event was received ``` **Cause:** When the underlying transport (WebSocket/MessagePort) has an error during workspace removal, ORPC throws `EVENT_ITERATOR_VALIDATION_FAILED` because the transport's `ErrorEvent` can't be validated against the chat message schema. **Fix:** Suppress this specific error only when the workspace has been removed (race condition between server error and client cleanup). If the workspace still exists and we get this error, it's logged as before since that would indicate a real problem. --- _Generated with `mux`_
1 parent 31c217f commit 7cd2c1f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

‎src/browser/components/ui/tooltip.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ const TooltipContent = React.forwardRef<
4646
));
4747
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
4848

49-
const HelpIndicator: React.FC<{ className?: string; children?: React.ReactNode }> = ({
50-
className,
51-
children,
52-
}) => (
49+
const HelpIndicator = React.forwardRef<
50+
HTMLSpanElement,
51+
{ className?: string; children?: React.ReactNode }
52+
>(({ className, children }, ref) => (
5353
<span
54+
ref={ref}
5455
className={cn("text-muted flex cursor-help items-center text-[10px] leading-none", className)}
5556
>
5657
{children}
5758
</span>
58-
);
59+
));
60+
HelpIndicator.displayName = "HelpIndicator";
5961

6062
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, TooltipArrow, HelpIndicator };

‎src/browser/stores/WorkspaceStore.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,21 @@ export class WorkspaceStore {
713713
});
714714
}
715715
} catch (error) {
716-
if (!signal.aborted) {
717-
console.error(
718-
`[WorkspaceStore] Error in onChat subscription for ${workspaceId}:`,
719-
error
720-
);
721-
}
716+
// Suppress errors when subscription was intentionally cleaned up
717+
if (signal.aborted) return;
718+
719+
// EVENT_ITERATOR_VALIDATION_FAILED with ErrorEvent cause happens when:
720+
// - The workspace was removed on server side (iterator ends with error)
721+
// - Connection dropped (WebSocket/MessagePort error)
722+
// Only suppress if workspace no longer exists (was removed during the race)
723+
const isIteratorError =
724+
error instanceof Error &&
725+
"code" in error &&
726+
error.code === "EVENT_ITERATOR_VALIDATION_FAILED";
727+
const workspaceRemoved = !this.states.has(workspaceId);
728+
if (isIteratorError && workspaceRemoved) return;
729+
730+
console.error(`[WorkspaceStore] Error in onChat subscription for ${workspaceId}:`, error);
722731
}
723732
})();
724733

0 commit comments

Comments
 (0)