Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(scripts): handle response parsing errors in queued attachment roundtrip

Steven Enamakel56af327596bc
diff --git a/scripts/debug/web-scripts/queued-image-attachment-roundtrip.mjs b/scripts/debug/web-scripts/queued-image-attachment-roundtrip.mjs
index 5776763757..5f7ff2a718 100644
--- a/scripts/debug/web-scripts/queued-image-attachment-roundtrip.mjs
+++ b/scripts/debug/web-scripts/queued-image-attachment-roundtrip.mjs
@@ -72,12 +72,23 @@ export default async function queuedImageAttachmentRoundtrip({
try {
const request = response.request();
const body = JSON.parse(request.postData() ?? "{}");
- rpcResponses.push({
- method: body.method,
- params: body.params,
- result: unwrap(await response.json()),
- });
- } catch {}
+ const responseBody = await response.json();
+ try {
+ rpcResponses.push({
+ method: body.method,
+ params: body.params,
+ result: unwrap(responseBody),
+ });
+ } catch (error) {
+ rpcResponses.push({
+ method: body.method,
+ params: body.params,
+ error: String(error),
+ });
+ }
+ } catch (error) {
+ rpcResponses.push({ error: String(error) });
+ }
});
// The mock captures a script when each model request starts. Hold the first
@@ -150,6 +161,7 @@ export default async function queuedImageAttachmentRoundtrip({
),
"the queued channel_web_chat acknowledgement",
);
+ if (queuedAckResponse.error) throw new Error(queuedAckResponse.error);
const ack = queuedAckResponse.result;
if (ack?.queued !== true || !ack.request_id) {
throw new Error(