agentgui 1.0.1123 → 1.0.1124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -124,15 +124,27 @@ export function safeErrMsg(err) {
124
124
 
125
125
  // Read a request body with a hard size cap; resolves a Buffer or rejects with
126
126
  // .code='TOO_LARGE' so the caller can answer 413 without buffering the rest.
127
+ // Stops accumulating further chunks (req.pause()) but does NOT destroy the
128
+ // socket - a destroyed request cannot carry the caller's 413 response back to
129
+ // the client, which instead sees a raw ECONNRESET with zero information
130
+ // (live-witnessed: fetch() reported only "fetch failed", no status code).
131
+ // The still-open connection is closed normally once the 413 response is sent.
127
132
  export function readBody(req, maxBytes) {
128
133
  return new Promise((resolve, reject) => {
129
- const chunks = []; let total = 0;
134
+ const chunks = []; let total = 0; let tooLarge = false;
130
135
  req.on('data', (c) => {
136
+ if (tooLarge) return;
131
137
  total += c.length;
132
- if (total > maxBytes) { const e = new Error('body too large'); e.code = 'TOO_LARGE'; req.destroy(); reject(e); return; }
138
+ if (total > maxBytes) {
139
+ tooLarge = true;
140
+ req.pause();
141
+ const e = new Error('body too large'); e.code = 'TOO_LARGE';
142
+ reject(e);
143
+ return;
144
+ }
133
145
  chunks.push(c);
134
146
  });
135
- req.on('end', () => resolve(Buffer.concat(chunks)));
147
+ req.on('end', () => { if (!tooLarge) resolve(Buffer.concat(chunks)); });
136
148
  req.on('error', reject);
137
149
  });
138
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.1123",
3
+ "version": "1.0.1124",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",