web: stop double-JSON-encoding the signal payload

Browser was JSON.stringify-ing the inner payload before putting it
in the outer message envelope. Go side then saw a JSON string where
it expected a JSON object, and SignalPayload Unmarshal silently
failed — which is why answers never made it back through the
peer connection.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude Opus 4.7
2026-05-21 00:56:38 -05:00
parent 09355e9914
commit ce020d641a

View File

@@ -164,7 +164,7 @@
type: "signal", type: "signal",
from: peerID, from: peerID,
source: "web", source: "web",
signal: JSON.stringify(payload), signal: payload,
}), }),
}); });
} }
@@ -216,8 +216,8 @@
try { try {
const m = JSON.parse(ev.data); const m = JSON.parse(ev.data);
if (m.from === peerID) return; // ignore our own if (m.from === peerID) return; // ignore our own
let payload = m.signal; const payload = m.signal;
if (typeof payload === "string") payload = JSON.parse(payload); if (!payload) return;
if (payload.kind === "offer" && payload.sdp) { if (payload.kind === "offer" && payload.sdp) {
handleOffer(payload.sdp.sdp); handleOffer(payload.sdp.sdp);
} else if (payload.kind === "ice" && payload.candidate) { } else if (payload.kind === "ice" && payload.candidate) {