Skip to content

Commit 872a481

Browse files
smart-notes: handle response-stream error on body-limit destroy
request.destroy(err) destroys the response stream with the same error; the request-level 'error' handler rejects the promise but the response side had no listener, so every body-limit / timeout / abort destroy also surfaced as an uncaught stream error on stderr. Co-authored-by: Alfonso [Magic Context] <288211368+alfonso-magic-context@users.noreply.github.com>
1 parent 6e421a6 commit 872a481

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • packages/plugin/src/features/magic-context/smart-notes

packages/plugin/src/features/magic-context/smart-notes/ssrf-guard.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ function requestValidatedAddress(
238238
}
239239
chunks.push(buf);
240240
});
241+
// request.destroy(err) (body limit, timeout, abort) also destroys
242+
// this response stream with the same error. Without a listener,
243+
// that becomes an UNCAUGHT stream 'error' dumped to stderr — the
244+
// request-level handler alone does not cover the response side.
245+
response.on("error", (error) => {
246+
reject(toNetworkError(error, "response failed"));
247+
});
241248
response.on("end", () => {
242249
const status = response.statusCode ?? 0;
243250
if (status >= 500) {

0 commit comments

Comments
 (0)