Explorar el Código

fix: SignalR provider - guard empty hub URLs (crypto/chat) to prevent 'url is required' crash (antooza pattern)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jino hace 6 horas
padre
commit
5f8b2e4c8f
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      contexts/signalrProvider.tsx

+ 10 - 0
contexts/signalrProvider.tsx

@@ -57,6 +57,11 @@ export function SignalRProvider({ children, accessToken, signalRCryptoUrl, signa
 	}, [chatConnected]);
 	}, [chatConnected]);
 
 
 	const initCryptoConnection = async () => {
 	const initCryptoConnection = async () => {
+		if (!signalRCryptoUrl) {
+			console.warn('SIGNALR_CRYPTO_URL not configured — crypto hub disabled');
+			return;
+		}
+
 		try {
 		try {
 			if (cryptoConnectionRef.current && cryptoConnectionRef.current.state !== signalR.HubConnectionState.Disconnected) {
 			if (cryptoConnectionRef.current && cryptoConnectionRef.current.state !== signalR.HubConnectionState.Disconnected) {
 				return;
 				return;
@@ -73,6 +78,11 @@ export function SignalRProvider({ children, accessToken, signalRCryptoUrl, signa
 	};
 	};
 
 
 	const initChatConnection = async (accessToken?: string|null) => {
 	const initChatConnection = async (accessToken?: string|null) => {
+		if (!signalRChatUrl) {
+			console.warn('SIGNALR_CHAT_URL not configured — chat hub disabled');
+			return;
+		}
+
 		try {
 		try {
 			if (chatConnectionRef.current && chatConnectionRef.current.state !== signalR.HubConnectionState.Disconnected) {
 			if (chatConnectionRef.current && chatConnectionRef.current.state !== signalR.HubConnectionState.Disconnected) {
 				await chatConnectionRef.current.stop();
 				await chatConnectionRef.current.stop();