{"record":{"id":"832f654df2a79a53","repo":"windmill-labs/windmill","slug":"not-connected-to-dap-server","errorCode":null,"errorMessage":"Not connected to DAP server","messagePattern":"Not connected to DAP server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/debug/dapClient.ts","lineNumber":170,"sourceCode":"\t}\n\n\t/**\n\t * Disconnect from the DAP server.\n\t */\n\tdisconnect(): void {\n\t\tif (this.ws) {\n\t\t\tthis.ws.close()\n\t\t\tthis.ws = null\n\t\t}\n\t\tdebugState.set({ ...initialState })\n\t}\n\n\t/**\n\t * Send a request to the DAP server and wait for a response.\n\t */\n\tprivate async sendRequest(command: string, args?: Record<string, unknown>): Promise<DAPMessage> {\n\t\tif (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n\t\t\tthrow new Error('Not connected to DAP server')\n\t\t}\n\n\t\tconst seq = this.seq++\n\t\tconst message: DAPMessage = {\n\t\t\tseq,\n\t\t\ttype: 'request',\n\t\t\tcommand,\n\t\t\targuments: args\n\t\t}\n\n\t\tconst timeoutMs = REQUEST_TIMEOUT_MS_BY_COMMAND[command] ?? DEFAULT_REQUEST_TIMEOUT_MS\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pendingRequests.delete(seq)\n\t\t\t\treject(new Error(`Request timeout: ${command} (after ${timeoutMs}ms)`))\n\t\t\t}, timeoutMs)\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/debug/dapClient.ts#L152-L188","documentation":"DapClient.sendRequest() is the single gateway for all Debug Adapter Protocol commands (launch, setBreakpoints, continue, stepOver, stepIn, configurationDone...). It throws 'Not connected to DAP server' when the underlying WebSocket is absent or not in OPEN state, so a request would otherwise be silently lost.","triggerScenarios":"Calling launch(), continue_(), stepOver(), stepIn(), configurationDone(), response(), etc. before connect() resolved, after the WebSocket closed (debuggee exited or server dropped), or while a reconnect is still in progress.","commonSituations":"Debugger UI buttons clicked after the debug session ended; the DAP server crashed or the websocket timed out mid-session; calling connect() without awaiting it before issuing commands; hot reload destroying the socket.","solutions":["Check the WebSocket connection state / onclose handler to find why the socket dropped (server exit, network, timeout).","Await connect() and only then send DAP commands; gate UI actions on a connected flag.","Restart the debug session (reconnect and re-launch) once the socket is OPEN again.","Inspect DAP server logs for a crash or unhandled adapter error preceding the disconnect.","Disable/queue stepping UI while readyState !== WebSocket.OPEN."],"exampleFix":"// before\nawait dapClient.launch(config) // throws if socket dropped\n// after\nif (!dapClient.isConnected()) { await dapClient.connect() }\nawait dapClient.launch(config)","handlingStrategy":"type-guard","validationCode":"// expose a public helper on DapClient, or check the socket state externally\n// if (!dapClient.isReady()) { await dapClient.connect() }","typeGuard":"function dapReady(client: DapClient): boolean {\n  return client['ws']?.readyState === WebSocket.OPEN\n}","tryCatchPattern":"try {\n  await dapClient.continue_(threadId)\n} catch (e) {\n  if (e.message === 'Not connected to DAP server') {\n    showToast('Debugger disconnected — restart the session')\n    await reconnectAndRelaunch()\n  } else throw e\n}","preventionTips":["Always await connect() before issuing any DAP command.","Track ws.onclose and disable stepping/continue buttons when closed.","Auto-reconnect and re-launch the session on unexpected close events.","Guard against double-connect during reconnection to avoid stale sockets."],"tags":["websocket","debugging","dap","connection-state"],"backgroundTag":"websocket-not-connected","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}