Repository navigation
Conversation
Check res.ok in Request.prototype.text() and throw an HTTP status error instead of returning non-ok error bodies to plain-text callers, guarding res.body?.cancel() so cancellation failures attach as cause on the thrown HTTP status error instead of masking it. Omit trailing whitespace when statusText is empty. Keep Request.prototype.json() reading res.text() directly so callers can still parse non-2xx JSON payloads. Move README loading in getCollaborators() inside its try/catch so fetch and file read errors stop the spinner as failed and rethrow the original error rather than leaving the spinner running, report nodejs/node/README.md for failed remote fetches, and stop the download spinner as failed in VotingSession.prototype.decryptKeyPart(). Fixes: nodejs#1253 Signed-off-by: dennev <dennev13@gmail.com>
This branch has not been deployed
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 #1253
Request.prototype.text()previously returnedres.text()without checkingres.ok. WhengetCollaborators()fetcheshttps://raw.githubusercontent.com/nodejs/node/HEAD/README.md, Commit Queue failure comments onnodejs/node#67292(workflow run45238634578at1a8cf16, landed at642300f7aa),#63746(workflow run28791968081), and#62795(workflow run24673051566) record the README parse error while those workflow runs finished with overallsuccessand#67292had#### TSC voting membersat both pinned revisions. Because live requests fetched the mutableHEADURL without logging raw HTTP details, their actual status and body remain unknown; a mocked503 Service UnavailableHTML response reproduces theCouldn't find #### TSC voting members in the READMEfailure becauseRequest.prototype.text()passes the response body toparseCollaborators(), while rejections fromrequest.text()orfs.readFileSync(readme)bypassed thetry/catchspinner cleanup.Changes:
fetchResponse()helper inlib/request.jsshared byRequest.prototype.text()andRequest.prototype.json(), preservingObject.create(Request.prototype)callers in tests.if (!res.ok)inRequest.prototype.text(), guardawait res.body?.cancel()intry/catch(attaching cancellation rejections, including falsy rejection reasons, ascauseon the HTTP status error so body cleanup never masks it), omit trailing whitespace on emptyres.statusText, and throwUnable to fetch <url>: <status>.Request.prototype.json()readingres.text()directly so callers handling non-2xx JSON payloads (query(),getTriagedReports(),PRBuild.prototype.getResults(), and CNA helpers) keep their existing behavior.try/catchblock inlib/collaborators.jssorequest.text()orfs.readFileSync(readme)failures stop the spinner cleanly, and report'nodejs/node/README.md'whenargv.readmeis omitted (omitting the option selects the remote README).this.req.text(...)inVotingSession.prototype.decryptKeyPart()(lib/voting_session.js) withtry/catchso rejecting HTTP responses stop the download spinner as failed beforerunPromise()exits incomponents/git/vote.js.test/unit/request.test.js,test/unit/collaborators.test.js, andtest/unit/voting_session.test.jscovering ok text, 503 with body cancellation, 502 withoutres.body, erroredReadableStreamcancel failure (TypeError('terminated')and falsyfalse/undefinedreasons), emptystatusText, non-okrequest.json(),request.text()rejection spinner cleanup, missing file at the suppliedargv.readmepath (ENOENTin at.after-cleaned directory), non-nodeargv.repospinner reporting, andVotingSession.prototype.decryptKeyPart()HTTP 503 spinner cleanup.Verification:
Node v24.22.2): before the fix (onv7.8.0andmain27468f5), 10 of the 12 new tests acrosstest/unit/request.test.js,test/unit/collaborators.test.js, andtest/unit/voting_session.test.jsfail (49 total, 39 passing, 10 failing: non-okrequest.text()body-present and missing-body cases resolve instead of rejecting; theTypeError('terminated')stream case rejects with'terminated'; the empty-statusTextcase throwsTypeError: res.text is not a function; the falsy-cancel test rejects withfalsewhereerr.message === undefined;getCollaborators()throwsCouldn't find #### TSC voting members in the READMEon mocked 503 HTML or skipsstopSpinneron fetch rejection orENOENT, including a fetch rejection for another repo; andVotingSession.prototype.decryptKeyPart()completes the mocked'<html>503</html>'fetch with'Download complete'(Service UnavailablestatusText) and throwsTypeError: Cannot read properties of undefined (reading 'map')instead of rejecting with HTTP 503 and failing the spinner), and on final commitfadebda682npm test,npm run lint, andnpm run coverage:cipassed (793 of 793 tests passing, 0 failed).AI disclosure: AI-assisted coding tools were used to investigate the cause, draft the fix, tests, and PR text, and review edge cases. I reviewed the diff, checked the failure logs and callers myself, and wrote/edited this description personally.
Happy to adjust the error message or scope if maintainers prefer another approach.