siyuan-note/siyuan · error · Error

failed to clear remote kernel active storage: " +…

Error message

failed to clear remote kernel active storage: " + error.message

What it means

Before connecting to a remote kernel, initRemoteKernel clears the default session's storage (cookies, localStorage, etc.) scoped to the target origin so stale credentials do not interfere. If the Electron session.clearStorageData call throws — origin malformed, storage type invalid, or an internal Chromium error — the original error is re-wrapped with this message.

Solutions

  1. Read error.message for the underlying cause (shown after the colon) and fix that specific issue
  2. Ensure the --remote origin is a clean protocol://host:port URL with no path, query, or fragment
  3. Upgrade or align Electron with the app's expected version if a storages type name is rejected
  4. Clear the app profile/cache directory manually if Chromium storage is corrupted, then relaunch

Example fix

// before
//   --remote "https://host:6806/siyuan"
// after (clean origin accepted by clearStorageData)
//   --remote "https://host:6806"
Defensive patterns

Strategy: validation

Validate before calling

if kek == nil {
    return errors.New("KEK must be derived before writing notebook crypto backup")
}

Type guard

func hasKEK(kek []byte) bool { return len(kek) > 0 }

Try / catch

if err := writeNotebookCryptoBackupData(nc, kek); err != nil {
    if err.Error() == "cannot generate notebook crypto backup without KEK" {
        // authenticate/derive KEK first, then retry
    }
}

Prevention

When it happens

Trigger: session.defaultSession.clearStorageData({origin: target.origin, storages: remoteKernelActiveStorageTypes}) rejects: invalid origin string (e.g. includes a path), a storage type name not recognized by the Electron version, or a Chromium session failure.

Common situations: A --remote origin containing a path or unusual characters; Electron/Chromium version mismatch making a storages entry invalid; corrupted profile or locked storage backend on disk; running in an environment where the default session is unavailable.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/aeb40d759c621e24. Report an issue: GitHub.

Appendix: source

Thrown at app/electron/main.js:2627

    if (!await showAppleSiliconWarning(getArg("--lang") || "")) {
        bootWindow.destroy();
        app.quit();
        return;
    }
    loadBootWindow();
    if (openAsHidden) {
        bootWindow.minimize();
    } else {
        bootWindow.show();
    }

    try {
        await session.defaultSession.clearStorageData({
            origin: target.origin,
            storages: remoteKernelActiveStorageTypes,
        });
    } catch (error) {
        throw new Error("failed to clear remote kernel active storage: " + error.message);
    }

    writeLog("connecting to remote kernel [origin=" + target.origin + "]");
    let versionData;
    for (let count = 0; count < 5; count++) {
        try {
            versionData = await requestRemoteKernelVersion(target);
            break;
        } catch (error) {
            writeLog("get remote kernel version failed: " + error.message);
            if (count < 4) {
                await sleep(500);
            }
        }
    }
    const versionStatus = getRemoteKernelVersionStatus(versionData, appVer);
    if (versionStatus === "invalid") {
        showErrorWindow("连接远程内核失败", "Failed to connect to the remote kernel",

View on GitHub (pinned to 8641553a1f)