Repository navigation
Description
In nodejs/node Commit Queue runs, git node land has intermittently failed during collaborator loading with Failed to get collaborator info from nodejs/node/README.md and Error: Couldn't find #### TSC voting members in the README, as recorded in Commit Queue failure comments on nodejs/node#67292 (workflow run 45238634578 at 1a8cf16), #63746 (workflow run 28791968081), and #62795 (workflow run 24673051566) while those workflow runs still reported overall success after posting the failure comment. On #67292, README.md contained #### TSC voting members at both the failed run revision 1a8cf16 and the landed revision 642300f7aa.
Cause: in lib/request.js, Request.prototype.text() returns res.text() without checking res.ok (unlike Request.prototype.stream()). In lib/collaborators.js, getCollaborators() fetches https://raw.githubusercontent.com/nodejs/node/HEAD/README.md via request.text(url) outside its try/catch block and passes the returned text directly to parseCollaborators(). The Commit Queue comments record the README parse error on live requests to the mutable HEAD URL without logging raw HTTP details, so their actual status and body remain unknown; in unit tests, a mocked 503 Service Unavailable HTML response reproduces that Couldn't find #### TSC voting members in the README error because Request.prototype.text() passes the response body to parseCollaborators(). Likewise, in lib/voting_session.js, VotingSession.prototype.decryptKeyPart() starts a spinner before await this.req.text(...), and in components/git/vote.js runPromise(...) calls process.exit(1) before .catch() can fail the active spinner if this.req.text(...) rejects.
Reproduced in unit tests with mocked Request.prototype.fetch() responses on both v7.8.0 and main (27468f5): simulating a 503 Service Unavailable HTML response in getCollaborators() reproduces the Couldn't find #### TSC voting members in the README parse failure because Request.prototype.text() resolves with the error body instead of rejecting. Unit tests also show that a direct rejection from request.text() or an ENOENT while reading the path in argv.readme skips stopSpinner(..., FAILED), and VotingSession.prototype.decryptKeyPart() finishes downloading a mocked '<html>503</html>' response (statusText: 'Service Unavailable') without failing its spinner and then hits TypeError on shares.map.
Proposed approach: in Request.prototype.text(), check if (!res.ok), attempt await res.body?.cancel() inside try/catch (logging cancellation rejections via debuglog and throwing the HTTP status error with { cause: err } so body cancellation failures attach as cause rather than masking the HTTP status), format the status by concatenating res.status and optional res.statusText without trailing whitespace when statusText is empty, and throw Unable to fetch <url>: <status>. Keep Request.prototype.json() reading res.text() directly via a shared fetchResponse() helper so callers that inspect non-2xx JSON payloads (query(), getTriagedReports(), PRBuild.prototype.getResults(), and CNA helpers) keep working unchanged. In lib/collaborators.js, move README loading inside try/catch and fall back to 'nodejs/node/README.md' when argv.readme is omitted (matching the hardcoded remote README URL). In lib/voting_session.js, catch download failures from this.req.text(...) inside decryptKeyPart() and call stopSpinner with SPINNER_STATUS.FAILED before rethrowing.
Trade-offs and alternatives: checking res.ok only inside getCollaborators() (by reading Response directly or adding a README-specific helper, which would bypass existing request.text stubs in caller tests such as test/unit/collaborators.test.js) would only cover the README fetch and leave Request.prototype.text() callers such as Job.prototype.getConsoleText() and VotingSession.prototype.decryptKeyPart() silently consuming HTTP error bodies. Making Request.prototype.text() enforce res.ok protects all plain-text callers without breaking request.json() error handling.
AI disclosure: AI-assisted coding tools helped investigate the cause, prepare the initial fix and tests, and draft this description, which I checked and edited personally.
Activity