fix(signal): guard JSON.parse of Signal RPC response with try-catch

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
adhitShet
2026-02-22 15:23:37 +01:00
committed by Peter Steinberger
co-authored by Claude Opus 4.6
parent 7d7297f57f
commit 4b78e91acd
+6 -1
View File
@@ -77,7 +77,12 @@ export async function signalRpcRequest<T = unknown>(
if (!text) {
throw new Error(`Signal RPC empty response (status ${res.status})`);
}
const parsed = JSON.parse(text) as SignalRpcResponse<T>;
let parsed: SignalRpcResponse<T>;
try {
parsed = JSON.parse(text) as SignalRpcResponse<T>;
} catch (err) {
throw new Error(`Signal RPC returned malformed JSON (status ${res.status})`, { cause: err });
}
if (parsed.error) {
const code = parsed.error.code ?? "unknown";
const msg = parsed.error.message ?? "Signal RPC error";