{"record":{"id":"a320eab38c8c004f","repo":"usebruno/bruno","slug":"failed-to-close-websocket-connection","errorCode":null,"errorMessage":"Failed to close WebSocket connection","messagePattern":"Failed to close WebSocket connection","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/components/RequestPane/WsQueryUrl/index.js","lineNumber":78,"sourceCode":"  }, [url, allVariables]);\n\n  // Debounce interpolated URL to avoid excessive reconnections\n  const debouncedInterpolatedURL = useDebounce(interpolatedURL, 400);\n  const previousDeboundedInterpolatedURL = useRef(debouncedInterpolatedURL);\n\n  const handleConnect = async () => {\n    setConnectionStatus(CONNECTION_STATUS.CONNECTING);\n    dispatch(wsConnectOnly(item, collection.uid));\n    previousDeboundedInterpolatedURL.current = debouncedInterpolatedURL;\n  };\n\n  const handleDisconnect = async (e, notify) => {\n    e && e.stopPropagation();\n    setConnectionStatus(CONNECTION_STATUS.DISCONNECTING);\n    try {\n      const result = await closeWsConnection(item.uid);\n      if (!result?.success) {\n        throw new Error(result?.error || 'Failed to close WebSocket connection');\n      }\n      notify && toast.success('WebSocket connection closed');\n      setConnectionStatus(CONNECTION_STATUS.DISCONNECTED);\n    } catch (err) {\n      console.error('Failed to close WebSocket connection:', err);\n      notify && toast.error('Failed to close WebSocket connection');\n      const statusResult = await getWsConnectionStatus(item.uid);\n      setConnectionStatus(statusResult?.status ?? CONNECTION_STATUS.DISCONNECTED);\n    }\n  };\n\n  const handleWsRun = (e) => {\n    e?.stopPropagation();\n    if (UNINTERACTIVE_STATES.includes(connectionStatus)) return;\n    if (!url) {\n      toast.error('Please enter a valid WebSocket URL');\n      return;\n    }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/components/RequestPane/WsQueryUrl/index.js#L60-L96","documentation":"Error \"Failed to close WebSocket connection\" thrown in usebruno/bruno.","triggerScenarios":"Thrown at packages/bruno-app/src/components/RequestPane/WsQueryUrl/index.js:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry closing the connection; the socket may already be closed.","Restart Bruno if the WebSocket state is stuck."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}