usebruno/bruno · error · Error

Failed to close WebSocket connection

Error message

Failed to close WebSocket connection

What it means

Error "Failed to close WebSocket connection" thrown in usebruno/bruno.

Source

Thrown at packages/bruno-app/src/components/RequestPane/WsQueryUrl/index.js:78

  }, [url, allVariables]);

  // Debounce interpolated URL to avoid excessive reconnections
  const debouncedInterpolatedURL = useDebounce(interpolatedURL, 400);
  const previousDeboundedInterpolatedURL = useRef(debouncedInterpolatedURL);

  const handleConnect = async () => {
    setConnectionStatus(CONNECTION_STATUS.CONNECTING);
    dispatch(wsConnectOnly(item, collection.uid));
    previousDeboundedInterpolatedURL.current = debouncedInterpolatedURL;
  };

  const handleDisconnect = async (e, notify) => {
    e && e.stopPropagation();
    setConnectionStatus(CONNECTION_STATUS.DISCONNECTING);
    try {
      const result = await closeWsConnection(item.uid);
      if (!result?.success) {
        throw new Error(result?.error || 'Failed to close WebSocket connection');
      }
      notify && toast.success('WebSocket connection closed');
      setConnectionStatus(CONNECTION_STATUS.DISCONNECTED);
    } catch (err) {
      console.error('Failed to close WebSocket connection:', err);
      notify && toast.error('Failed to close WebSocket connection');
      const statusResult = await getWsConnectionStatus(item.uid);
      setConnectionStatus(statusResult?.status ?? CONNECTION_STATUS.DISCONNECTED);
    }
  };

  const handleWsRun = (e) => {
    e?.stopPropagation();
    if (UNINTERACTIVE_STATES.includes(connectionStatus)) return;
    if (!url) {
      toast.error('Please enter a valid WebSocket URL');
      return;
    }

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Retry closing the connection; the socket may already be closed.
  2. Restart Bruno if the WebSocket state is stuck.

When it happens

Trigger: Thrown at packages/bruno-app/src/components/RequestPane/WsQueryUrl/index.js:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/a320eab38c8c004f. Report an issue: GitHub.