Skip to content

fix: handle request errors when fetching CODEOWNERS - #708

Open
NopeCharon wants to merge 1 commit into
nodejs:mainfrom
NopeCharon:fix/codeowners-request-error
Open

NopeCharon wants to merge 1 commit into
nodejs:mainfrom
NopeCharon:fix/codeowners-request-error

Conversation

@NopeCharon

Copy link
Copy Markdown

Fixes #705

getCodeOwnersFile() listened for 'err' on the https request, but ClientRequest emits 'error'. Network-level failures (DNS, ECONNRESET, socket hang up, TLS) were thrown as uncaught exceptions that terminate the bot. Because the promise never rejected, the surrounding Aigle.retry() never retried.

Changes:

  • listen for 'error' on the request
  • reject on 'error' from the response stream too, for a connection dropped mid-body
  • drain the body of non-200 responses with res.resume() so the socket is released

Testing

  • New unit test that uses nock(...).replyWithError() and expects a rejection. Without the fix it fails with failureType: 'uncaughtException'.
  • npm test passes.

getCodeOwnersFile() listened for an 'err' event on the https request,
which ClientRequest never emits; failures are emitted as 'error'. Any
network-level failure (DNS, ECONNRESET, socket hang up, TLS) therefore
had no listener, was thrown as an uncaught exception and terminated the
bot through the uncaughtException handler in server.js, instead of
rejecting the promise and letting the surrounding Aigle.retry() retry.

Listen for 'error' on the request, also reject on errors emitted by the
response stream (e.g. a connection dropped mid-body), and drain the
body of non-200 responses so the socket is released.

Add a unit test that makes the request fail at the network level and
expects getCodeOwnersFile() to reject; it fails with an uncaught
exception without this change.

Fixes: nodejs#705
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon requested a review from a team as a code owner October 24, 2026 06:56
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.

Network errors while fetching CODEOWNERS crash the bot instead of being retried

1 participant