siyuan-note/siyuan · error · Error

window.siyuan.languages._kernel[28]

Error message

window.siyuan.languages._kernel[28]

What it means

After a successful HTTP response, fetchAIEditorSSE requires a readable response body stream. If `response.body` is null (no ReadableStream available), it throws `window.siyuan.languages._kernel[28]` (localized generic network error), because SSE streaming cannot proceed without a stream reader.

Solutions

  1. Upgrade Electron/Chromium to a version supporting fetch ReadableStream (Chromium 43+ / stable streaming fetch in 105+)
  2. Do not replace native fetch with a polyfill that omits `body`
  3. Check that no service worker strips the response body
  4. Fall back to a non-streaming AI request if streaming is unsupported

Example fix

// before
const reader = response.body?.getReader();
if (!reader) {
    throw new Error(window.siyuan.languages._kernel[28]);
}
// after: fail with a clearer, actionable message
const reader = response.body?.getReader();
if (!reader) {
    throw new Error("Streaming responses are not supported in this environment; update the app or disable AI streaming");
}
Defensive patterns

Strategy: type-guard

Validate before calling

const supportsStreaming = typeof Response !== "undefined" && new Response().body instanceof ReadableStream;

Type guard

const hasBodyStream = (res: Response): res is Response & {body: ReadableStream} => res.body instanceof ReadableStream;

Try / catch

try {
    await fetchAIEditorSSE(url, data, onEvent);
} catch (e) {
    showMessage(window.siyuan.languages._kernel[28]); // environment cannot stream; suggest updating the app
}

Prevention

When it happens

Trigger: `response.body?.getReader()` returns undefined — occurs in environments without ReadableStream support (very old browsers/webviews, some Electron builds with experimental web features disabled) or when the response body was already consumed.

Common situations: Running the app in an outdated Electron/Chromium build or an embedded webview lacking fetch streaming support; polyfills that stub fetch without body streams.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/ff24d2654d6e4197. Report an issue: GitHub.

Appendix: source

Thrown at app/src/ai/editorSSE.ts:114

        method: "POST",
        headers: {"Content-Type": "application/json"},
        body: JSON.stringify(request),
        signal,
    });
    const contentType = response.headers.get("Content-Type") || "";
    if (!response.ok || !contentType.includes("text/event-stream")) {
        let message = window.siyuan.languages._kernel[28];
        try {
            const data = await response.json();
            message = data?.msg || data?.message || message;
        } catch (e) {
            // 响应不是 JSON 时使用统一错误文案。
        }
        throw new Error(message);
    }
    const reader = response.body?.getReader();
    if (!reader) {
        throw new Error(window.siyuan.languages._kernel[28]);
    }
    const decoder = new TextDecoder();
    const parserState = createAIEditorSSEParserState();
    let terminalReceived = false;
    while (true) {
        const result = await reader.read();
        if (result.done) {
            break;
        }
        parseAIEditorSSE(parserState, decoder.decode(result.value, {stream: true})).forEach(event => {
            terminalReceived = terminalReceived || event.type === "done" || event.type === "error";
            onEvent(event);
        });
    }
    parseAIEditorSSE(parserState, decoder.decode(), true).forEach(event => {
        terminalReceived = terminalReceived || event.type === "done" || event.type === "error";
        onEvent(event);
    });

View on GitHub (pinned to 9f775e8a12)