mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 11:52:26 +03:00
fix(sse): absorb AbortError/request_signal_aborted in the client-abort crash guard (#12165)
OmniRoute's SSE teardown aborts in-flight legs with `Error [AbortError]: request_signal_aborted` on client disconnects (open-sse/utils/streamHandler.ts getClientAbortReason), and fetch/DOM cancellation surfaces as AbortError with an abort-flavoured message. isClientAbortError() only matched message 'aborted'/'Aborted' plus errno codes, so these shapes fell through shouldSwallowUncaught() and were re-thrown from the process-level uncaughtException/unhandledRejection handlers — killing the whole server on a routine client disconnect (observed as repeated exit-code-7 crashes with 'uncaughtException: Error [AbortError]: request_signal_aborted'). Match AbortError by name when the message is abort-flavoured; genuine errors that merely mention 'abort' (e.g. TypeError) still crash loudly. Tests: new unit cases for the SSE/DOM AbortError shapes, a child-process regression proving the process survives both benign emissions with the production no-logger install shape, and a child-process test proving genuine errors keep crash semantics.
This commit is contained in:
@@ -42,6 +42,13 @@ export function isClientAbortError(err) {
|
||||
const e = /** @type {NodeJS.ErrnoException} */ (err);
|
||||
// Node emits `Error: aborted` (no code) from http.Server#abortIncoming.
|
||||
if (e.message === "aborted" || e.message === "Aborted") return true;
|
||||
// OmniRoute's SSE teardown aborts in-flight legs with
|
||||
// `Error [AbortError]: request_signal_aborted` on client disconnects
|
||||
// (open-sse/utils/streamHandler.ts), and fetch/DOM cancellation surfaces as
|
||||
// `AbortError` with an abort-flavoured message. Same benign class as
|
||||
// `Error: aborted` — an emitter-left 'error' event on any of these used to
|
||||
// kill the process (#fix-dev-server-aborted).
|
||||
if (e.name === "AbortError" && /abort/i.test(String(e.message))) return true;
|
||||
switch (e.code) {
|
||||
case "ERR_STREAM_PREMATURE_CLOSE":
|
||||
case "ECONNRESET":
|
||||
|
||||
Reference in New Issue
Block a user