On this page

RemoteErrorDecodeError

Trace a marked SER failure envelope whose encoded value cannot be decoded.

What this error means and what can trigger it

RemoteErrorDecodeError means the client recognized SER's serialized remote-failure envelope but could not decode its payload. Recognizing the envelope matters here: arbitrary invalid JSON does not trigger this class. The value must first carry the marker identifying it as a serialized SER failure.

When the adapter supplies a custom payload decoder, SER uses it; otherwise, it falls back to devalue's parse. A thrown decoder exception or invalid result produces the internal invalid state, while the original wire value remains available in raw.

Client effects see RemoteTransportError. Its cause is this class and its body is the same raw value.

Exactly where it triggers

const serialized = decode_serialized_remote_failure(raw);

if (serialized._tag === "SerializedRemoteFailureInvalid") {
	return create_remote_transport_error(new RemoteErrorDecodeError(raw), raw);
}

The decoder catches those failures here:

try {
	const decoded = decode_payload ? decode_payload(envelope.encoded) : parse(envelope.encoded);

	return { _tag: "SerializedRemoteFailureDecoded", decoded };
} catch {
	return { _tag: "SerializedRemoteFailureInvalid" };
}

For reference, the class itself is declared at modules/svelte-effect-runtime/src/errors.ts L728 @ C14; the construction above is its only production use.

Why this is the case

The marker says the server intended to preserve a typed effect failure across the remote boundary. Returning the encoded value as ordinary data would silently turn a failed effect into a successful one, while treating it as an unknown domain failure would invent a tag the client never decoded.

The transport wrapper reports that the representation failed before application meaning could be restored. Keeping raw makes codec and version mismatches inspectable without allowing the malformed payload into the typed failure union.