Repository navigation
fix: handle request errors when fetching CODEOWNERS - #708
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #705
getCodeOwnersFile()listened for'err'on the https request, butClientRequestemits'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 surroundingAigle.retry()never retried.Changes:
'error'on the request'error'from the response stream too, for a connection dropped mid-bodyres.resume()so the socket is releasedTesting
nock(...).replyWithError()and expects a rejection. Without the fix it fails withfailureType: 'uncaughtException'.npm testpasses.