{"record":{"id":"2dd96c92da337a74","repo":"oven-sh/bun","slug":"aborted","errorCode":"Aborted","errorMessage":"Aborted","messagePattern":"Aborted","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"info","filePath":"src/http/error.rs","lineNumber":6,"sourceCode":"#[allow(non_camel_case_types)]\n#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]\npub enum Error {\n    #[error(\"CompressionFailed\")]\n    CompressionFailed,\n    #[error(\"Aborted\")]\n    Aborted,\n    #[error(\"WriteFailed\")]\n    WriteFailed,\n    #[error(\"HTTP2RefusedStream\")]\n    HTTP2RefusedStream,\n    #[error(\"HTTP2ContentLengthMismatch\")]\n    HTTP2ContentLengthMismatch,\n    #[error(\"HTTP2FrameSizeError\")]\n    HTTP2FrameSizeError,\n    #[error(\"HTTP2ProtocolError\")]\n    HTTP2ProtocolError,\n    #[error(\"HTTP2FlowControlError\")]\n    HTTP2FlowControlError,\n    #[error(\"HTTP2EnhanceYourCalm\")]\n    HTTP2EnhanceYourCalm,\n    #[error(\"HTTP2HeaderListTooLarge\")]\n    HTTP2HeaderListTooLarge,\n    #[error(\"HTTP2StreamReset\")]","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/http/error.rs#L1-L24","documentation":"The in-flight request was aborted before completion. It is set when a fetch/request is torn down deliberately: AbortController signal, connection close_and_fail during teardown (src/http/lib.rs:2100, :3938), or the HTTP/2/3 session cancelling the stream (src/http/h2_client/ClientSession.rs:463, :989). is_abort() maps it (and AbortedBeforeConnecting) to CommonAbortReason::UserAbort (src/http/lib.rs:505-510), and JS typically sees it as an AbortError DOMException.","triggerScenarios":"Calling abortController.abort() while a fetch is running; a request aborted because its initiator (JS scope) went away; h2 session teardown failing pending waiters with Aborted; S3 helper paths storing Error::Aborted as the terminal request error.","commonSituations":"React/strict frameworks aborting fetches on unmount; timeout wrappers built on AbortSignal.timeout(); shared h2 connections dropped when a sibling request kills the session; tests that abort requests to verify cancellation handling.","solutions":["Confirm the abort is intentional: log signal.reason in the catch block — AbortSignal.timeout gives a TimeoutError reason, user aborts give your own reason.","If the abort is collateral (session-level), retry idempotent requests with the same body — buffered bodies are reusable.","For timeout-driven aborts, raise the timeout or use AbortSignal.any to separate user-cancel from deadline.","Ensure you don't abort a controller shared by multiple fetches unintentionally."],"exampleFix":"// before: abort surprises the caller\nconst res = await fetch(url, { signal }); // rejects with AbortError, unhandled path\n// after: distinguish reasons\ntry {\n  const res = await fetch(url, { signal });\n} catch (err) {\n  if (err.name === 'AbortError') {\n    if (signal.reason?.name === 'TimeoutError') return retry(url);\n    return; // intentional cancel\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"if (signal?.aborted) throw signal.reason ?? new Error('aborted before start');\nconst res = await fetch(url, { signal });","typeGuard":"function isAbortError(err) {\n  return err instanceof Error && err.name === 'AbortError';\n}\nfunction isTimeoutAbort(signal) {\n  return signal?.reason instanceof Error && signal.reason.name === 'TimeoutError';\n}","tryCatchPattern":"try {\n  return await fetch(url, { signal });\n} catch (err) {\n  if (isAbortError(err)) {\n    if (isTimeoutAbort(signal)) return retryWithFreshSignal(url);\n    return; // user-initiated cancel — swallow\n  }\n  throw err;\n}","preventionTips":["Give every fetch its own controller unless shared cancellation is intended","Separate user-cancel from deadlines via AbortSignal.any([userSignal, AbortSignal.timeout(ms)])","Always handle AbortError in wrappers so cancellations don't surface as bugs"],"tags":["http","fetch","abort","network","cancellation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}