wavetermdev/waveterm · error

msg.error

Error message

msg.error

What it means

rpcResponseGenerator consumes queued streaming RPC responses; when a message carries an `error` field, it throws that error into the generator's consumer. This propagates a remote-side failure (from the peer that produced the stream) to the local caller awaiting the stream.

Source

Thrown at frontend/app/store/wshrpcutil-base.ts:50

    const msgFn = (msg: RpcMessage) => {
        msgQueue.push(msg);
        signalFn();
        // reset signal promise
        signalPromise = new Promise<void>((resolve) => (signalFn = resolve));
    };
    openRpcs.set(reqid, {
        reqId: reqid,
        startTs: Date.now(),
        command: command,
        msgFn: msgFn,
    });
    yield null;
    try {
        while (true) {
            while (msgQueue.length > 0) {
                const msg = msgQueue.shift()!;
                if (msg.error != null) {
                    throw new Error(msg.error);
                }
                if (!msg.cont && msg.data == null) {
                    return;
                }
                const shouldTerminate = yield msg.data;
                if (shouldTerminate) {
                    sendRpcCancel(reqid);
                    return;
                }
                if (!msg.cont) {
                    return;
                }
            }
            await signalPromise;
        }
    } finally {
        openRpcs.delete(reqid);
        if (timeoutId != null) {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Read the thrown message — it is the remote error text — and fix the root cause on the producing side
  2. Wrap the streaming consumption loop in try/catch to handle remote failures gracefully
  3. Check authentication/permissions if the error indicates denial; retry after correcting the request

Example fix

// before
for await (const chunk of gen) { process(chunk); }

// after
try {
    for await (const chunk of gen) { process(chunk); }
} catch (e) {
    console.error("stream failed:", e.message);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (msg?.error != null) {
    // handle remote error before consuming stream
    console.error("remote rpc error:", msg.error);
}

Type guard

function isRpcError(msg: RpcMessage): boolean {
    return msg != null && (msg as any).error != null;
}

Try / catch

const gen = rpcResponseHelper...();
try {
    for await (const data of gen) { handle(data); }
} catch (e) {
    // e.message is the remote error string
    reportRemoteError(e.message);
}

Prevention

When it happens

Trigger: An RpcMessage in the streaming response queue has msg.error != null — i.e. the remote endpoint sent an explicit error frame instead of data.

Common situations: Remote handler threw while producing stream chunks; permission denial from the server for the requested command; network/protocol error reported mid-stream by the peer.

Related errors


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