diff --git a/apps/sim/app/workspace/providers/socket-provider.tsx b/apps/sim/app/workspace/providers/socket-provider.tsx index 9a63092f97..cf1e8d4836 100644 --- a/apps/sim/app/workspace/providers/socket-provider.tsx +++ b/apps/sim/app/workspace/providers/socket-provider.tsx @@ -409,6 +409,9 @@ export function SocketProvider({ children, user }: SocketProviderProps) { error.message?.includes('Authentication failed') || error.message?.includes('Authentication required') + // Check if this is a permanent configuration error — retrying won't help + const isNamespaceError = error.message?.includes('Invalid namespace') + if (isAuthError) { logger.warn( 'Authentication failed - stopping reconnection attempts. User may need to refresh/re-login.' @@ -418,6 +421,16 @@ export function SocketProvider({ children, user }: SocketProviderProps) { setAuthFailed(true) setIsReconnecting(false) initializedRef.current = false + } else if (isNamespaceError) { + logger.warn( + 'Invalid namespace error - stopping reconnection attempts. Check NEXT_PUBLIC_SOCKET_URL configuration.', + { message: error.message } + ) + socketInstance.disconnect() + setSocket(null) + setAuthFailed(true) + setIsReconnecting(false) + initializedRef.current = false } else if (socketInstance.active) { // Temporary failure, will auto-reconnect setIsReconnecting(true)