router icon indicating copy to clipboard operation
router copied to clipboard

DOMException: The connection was closed is not catchable

Open checkerschaf opened this issue 1 month ago โ€ข 1 comments

Which project does this relate to?

Start

Describe the bug

When a client disconnects during streaming, the resulting DOMException: The connection was closed cannot be caught and floods the production server logs.

This issue often arises from bots or users closing the tab while streaming is still in progress.

Your Example Website or App

https://github.com/checkerschaf/start-domexception-aborterror

Steps to Reproduce the Bug or Issue

  1. Clone the reproduction repo
  2. Run bun install
  3. Run bun run build
  4. Start the server: bun run bun-server.ts
  5. Run the script bun run reproduce-abort-error.ts in a new terminal while the server is running

Expected behavior

No errors in the server console and the streaming cancellation should be handled gracefully.

Screenshots or Videos

No response

Platform

  • Start Version: 1.140.5
  • Bun: 1.3.4

Additional context

Full error logs:

error: The connection was closed.
      cause: DOMException {
  line: 4174,
  column: 32,
  sourceURL: "/Users/xyz/tart-domexception-aborterror/node_modules/react-dom/cjs/react-dom-server.bun.production.js",
  stack: "@/Users/xyz/tart-domexception-aborterror/node_modules/react-dom/cjs/react-dom-server.bun.production.js:4174:32\nPromise@\n@/Users/xyz/tart-domexception-aborterror/node_modules/react-dom/cjs/react-dom-server.bun.production.js:4137:23\n@/Users/xyz/tart-domexception-aborterror/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js:12:63\nrenderRouterToStream@/Users/xyz/tart-domexception-aborterror/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js:5:37\n@/Users/xyz/tart-domexception-aborterror/dist/server/server.js:315:32\nprocessTicksAndRejections@",
  code: 20,
  name: "AbortError",
  message: "The connection was closed.",
  INDEX_SIZE_ERR: 1,
  DOMSTRING_SIZE_ERR: 2,
  HIERARCHY_REQUEST_ERR: 3,
  WRONG_DOCUMENT_ERR: 4,
  INVALID_CHARACTER_ERR: 5,
  NO_DATA_ALLOWED_ERR: 6,
  NO_MODIFICATION_ALLOWED_ERR: 7,
  NOT_FOUND_ERR: 8,
  NOT_SUPPORTED_ERR: 9,
  INUSE_ATTRIBUTE_ERR: 10,
  INVALID_STATE_ERR: 11,
  SYNTAX_ERR: 12,
  INVALID_MODIFICATION_ERR: 13,
  NAMESPACE_ERR: 14,
  INVALID_ACCESS_ERR: 15,
  VALIDATION_ERR: 16,
  TYPE_MISMATCH_ERR: 17,
  SECURITY_ERR: 18,
  NETWORK_ERR: 19,
  ABORT_ERR: 20,
  URL_MISMATCH_ERR: 21,
  QUOTA_EXCEEDED_ERR: 22,
  TIMEOUT_ERR: 23,
  INVALID_NODE_TYPE_ERR: 24,
  DATA_CLONE_ERR: 25,
  toString: [Function: toString],
},
     status: 500,
 statusText: undefined,
    headers: undefined,
       data: undefined,
       body: undefined,
  unhandled: true,

      at /Users/xyz/tart-domexception-aborterror/node_modules/h3-v2/dist/h3.mjs:315:41

checkerschaf avatar Dec 11 '25 15:12 checkerschaf

๐Ÿ“ CodeRabbit Plan Mode

Generate an implementation plan and prompts that you can use with your favorite coding agent.

  • [ ] Create Plan
Examples

๐Ÿ”— Related PRs

TanStack/router#6024 - fix(start): fix stream handling on cloudflare [merged]

๐Ÿ‘ค Suggested Assignees

  • 7x7cl

๐Ÿงช Issue enrichment is currently in early access.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

coderabbitai[bot] avatar Dec 11 '25 15:12 coderabbitai[bot]