{"record":{"id":"6301ce454bb7af36","repo":"wavetermdev/waveterm","slug":"window-windowid-not-found","errorCode":null,"errorMessage":"window ${windowId} not found","messagePattern":"window (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"emain/emain-wsh.ts","lineNumber":53,"sourceCode":"        new Notification({\n            title: notificationOptions.title,\n            body: notificationOptions.body,\n            silent: notificationOptions.silent,\n        }).show();\n    }\n\n    async handle_getupdatechannel(rh: RpcResponseHelper): Promise<string> {\n        return getResolvedUpdateChannel();\n    }\n\n    async handle_focuswindow(rh: RpcResponseHelper, windowId: string) {\n        console.log(`focuswindow ${windowId}`);\n        const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);\n        let ww = getWaveWindowById(windowId);\n        if (ww == null) {\n            const window = await WindowService.GetWindow(windowId);\n            if (window == null) {\n                throw new Error(`window ${windowId} not found`);\n            }\n            ww = await createBrowserWindow(window, fullConfig, {\n                unamePlatform,\n                isPrimaryStartupWindow: false,\n            });\n        }\n        ww.focus();\n    }\n\n    async handle_electronencrypt(\n        rh: RpcResponseHelper,\n        data: CommandElectronEncryptData\n    ): Promise<CommandElectronEncryptRtnData> {\n        if (!safeStorage.isEncryptionAvailable()) {\n            throw new Error(\"encryption is not available\");\n        }\n        const encrypted = safeStorage.encryptString(data.plaintext);\n        const ciphertext = encrypted.toString(\"base64\");","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/emain/emain-wsh.ts#L35-L71","documentation":"OpenDomainSocketListener may only run when the WslConn is in Status_Connecting. Under the connection lock it checks the status; if the connection is in any other state (connected, connecting through another path, disconnected), this error names both the connection and its current status. It guards against double-initializing the domain socket listener.","triggerScenarios":"tryEnableWsh calls OpenDomainSocketListener on a conn whose Status is not Status_Connecting — e.g. already connected, or a concurrent routine changed the status first.","commonSituations":"Calling tryEnableWsh twice concurrently; wsh already enabled and connected; connection in error/disconnected state after a drop; racing an in-flight reconnect.","solutions":["Check conn.GetStatus() before calling; only invoke during Status_Connecting","Avoid calling twice — let the existing enable flow finish before re-invoking","If the connection is already connected, the listener is likely already set up; no action needed","Serialize enable/reconnect calls so status transitions don't race"],"exampleFix":"// before\nconn.OpenDomainSocketListener(ctx) // fails if status != Connecting\n// after\nif conn.GetStatus() == wslconn.Status_Connecting {\n    err := conn.OpenDomainSocketListener(ctx)\n}","handlingStrategy":"type-guard","validationCode":"if conn.GetStatus() != wslconn.Status_Connecting {\n    return nil // listener can only be opened while connecting\n}","typeGuard":"func canOpenListener(s string) bool { return s == wslconn.Status_Connecting }","tryCatchPattern":"err := conn.OpenDomainSocketListener(ctx)\nif err != nil && strings.Contains(err.Error(), \"cannot open domain socket\") {\n    // conn already past Connecting; skip or wait for status transition\n}","preventionTips":["Always check GetStatus() == Status_Connecting before enabling wsh","Serialize enable flows with a mutex/flag to prevent double invocation","Treat 'already connected' as success rather than an error path"],"tags":["wsl","connection-state","domain-socket","race-condition"],"backgroundTag":"invalid-connection-state","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}