Skip to content

fix(diagnostics): handle socket errors after timeout cleanup - #22236

Draft
OrcaWin wants to merge 1 commit into
mainfrom
codex/memory-diagnostic-http-teardown-0922
Draft

OrcaWin wants to merge 1 commit into
mainfrom
codex/memory-diagnostic-http-teardown-0922

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4

ELI5

A diagnostic upload that timed out before receiving response headers could trigger an unhandled socket error after reporting its timeout. The cleanup now safely absorbs the later error.

What Changed

Install a callback that captures no request data before destroying the HTTP request. Existing callbacks and buffered response data can still be released by the normal cleanup path.

Why

Node can emit ECONNRESET asynchronously after destroy(). Removing every error callback before that event turned successful timeout cleanup into an unhandled error. A small static callback handles that event without keeping the upload's captured data alive.

Linked Issue

N/A — found during the requested resource-lifetime audit; tracking stays local.

Visual Proof

N/A — request teardown has no UI change.

Testing

  • Before: a local HTTP server withholding headers reproduced the timeout rejection followed by an unhandled socket hang up and process exit 1. The same probe exits 0 after the change.
  • Four tests pass, including five real loopback timeout cycles with all accepted sockets closing, plus existing success/error/size-limit cleanup tests.
  • Node typecheck, changed-code-quality gate, formatting, and diff checks pass. Tests used ORCA_BACKGROUND_LAUNCH=1; no diagnostics were sent to an external endpoint.

AI Disclosure

Implemented and reviewed with Codex.

Review

Reviewed Node request event ordering and ensured the new callback has no closure over payloads. The timeout error and response size limit are unchanged.

Agent skill upstream boundary

  • Not applicable.

Notes

This is an error-listener lifetime defect found by the audit, not evidence of a memory leak. The shared Node HTTP path covers local clients regardless of workspace or execution host.

Checklist

  • Focused change with concrete before/after evidence.
  • Cross-platform and SSH/remote impact considered.
  • Full repository test and build (focused checks passed; CI covers the rest).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant