wavetermdev/waveterm · error

encryption is not available

Error message

encryption is not available

What it means

StartConnServer launches the remote wsh connserver and, like OpenDomainSocketListener, is only permitted while the WslConn status is Status_Connecting. If the lock-protected status check fails, it returns this error with the connection name and actual status. It prevents starting a second conn server for an already-established or already-failed connection.

Source

Thrown at emain/emain-wsh.ts:68

        if (ww == null) {
            const window = await WindowService.GetWindow(windowId);
            if (window == null) {
                throw new Error(`window ${windowId} not found`);
            }
            ww = await createBrowserWindow(window, fullConfig, {
                unamePlatform,
                isPrimaryStartupWindow: false,
            });
        }
        ww.focus();
    }

    async handle_electronencrypt(
        rh: RpcResponseHelper,
        data: CommandElectronEncryptData
    ): Promise<CommandElectronEncryptRtnData> {
        if (!safeStorage.isEncryptionAvailable()) {
            throw new Error("encryption is not available");
        }
        const encrypted = safeStorage.encryptString(data.plaintext);
        const ciphertext = encrypted.toString("base64");

        let storagebackend = "";
        if (process.platform === "linux") {
            storagebackend = safeStorage.getSelectedStorageBackend();
        }

        return {
            ciphertext,
            storagebackend,
        };
    }

    async handle_electrondecrypt(
        rh: RpcResponseHelper,
        data: CommandElectronDecryptData

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify conn.GetStatus() is Status_Connecting before calling
  2. If the conn is already connected, skip StartConnServer — the server is already running
  3. De-duplicate enable flows (guard with a flag or mutex) so it is only invoked once
  4. If status is disconnected/error, reconnect the base connection first

Example fix

// before
conn.StartConnServer(ctx, false) // fails unless status == Connecting
// after
if conn.GetStatus() != wslconn.Status_Connecting {
    return nil // already connected or not ready; skip server start
}
started, _, _, err := conn.StartConnServer(ctx, false)
Defensive patterns

Strategy: type-guard

Validate before calling

if conn.GetStatus() != wslconn.Status_Connecting {
    return nil // server already started or conn not ready
}

Type guard

func canStartServer(s string) bool { return s == wslconn.Status_Connecting }

Try / catch

started, _, _, err := conn.StartConnServer(ctx, false)
if err != nil && strings.Contains(err.Error(), "cannot start conn server") {
    // inspect conn.GetStatus(); skip if already connected
}

Prevention

When it happens

Trigger: tryEnableWsh calls StartConnServer when Status is not Status_Connecting — e.g. already connected, already starting, or disconnected.

Common situations: Concurrent/attempted duplicate StartConnServer calls; conn already fully connected so no server start is needed; connection transitioned to error state between calls; racing reconnect flows.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/b3652ccf3f067a21. Report an issue: GitHub.