| 9 | let cachedClient: any; |
| 10 | |
| 11 | function decodePrpcError(buffer: Uint8Array) { |
| 12 | try { |
| 13 | if (buffer && buffer.length > 0) { |
| 14 | const err = prpc.PrpcError.decode(buffer); |
| 15 | if (err?.message) { |
| 16 | return err.message; |
| 17 | } |
| 18 | } |
| 19 | } catch { |
| 20 | // Ignore decode failures; fall through to text decoding. |
| 21 | } |
| 22 | try { |
| 23 | const text = buffer && buffer.length > 0 ? textDecoder.decode(buffer) : ''; |
| 24 | return text || 'Unknown RPC error'; |
| 25 | } catch { |
| 26 | return 'Unknown RPC error'; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | function normalizeRequestData(data?: Uint8Array | ArrayBuffer | null) { |
| 31 | if (!data) { |