Repository navigation
Description
What happens
npm install -g (and the action's "Install OpenCodeReview" step) downloads the release binary with https.get and no timeout of any kind. If the connection stalls — a black-holed proxy, a CDN that accepts the connection and then sends nothing, a dropped route — neither 'error' nor 'end' ever fires and the install waits forever. In a GitHub Actions job that means the runner's default 360-minute job timeout, with a paid review never started.
scripts/install.js:93-116:
function download(url, maxRedirects = 10) {
if (!url.startsWith("https")) { ... }
if (maxRedirects <= 0) { ... }
return new Promise((resolve, reject) => {
https.get(url, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
res.resume();
download(res.headers.location, maxRedirects - 1).then(resolve).catch(reject);
return;
}
if (res.statusCode !== 200) {
res.resume();
reject(new Error(`HTTP ${res.statusCode} fetching ${url}`));
return;
}
resolve(res);
}).on("error", reject);
});
}https.get(url, cb) is called with no options object, so there is no timeout. There is no req.on("timeout", ...) either — and a bare timeout option alone would not be enough, since Node emits 'timeout' without destroying the socket.
Two distinct stalls are unguarded:
- Before the response. The connection is accepted but no headers arrive.
resnever fires, and the promise never settles. - During the body.
download()already resolved withres, anddownloadBinary(scripts/install.js:128-146) pipes it to a file:res.pipe(fileStream)withfinishas the only success path. A body that stops mid-stream leaves the file stream open and the promise pending.
The same repo already guards this twice elsewhere
scripts/update.js:86-111— the self-updater's registry fetch setstimeout: 15000and attachesreq.on("timeout", () => { req.destroy(); ... }).install.sh:61— the shell installer's binary download usescurl -fL --connect-timeout 5 --speed-limit 1024 --speed-time 30, i.e. both a connect bound and a stall bound (--speed-time 30aborts when throughput stays under 1 KB/s for 30 s).
So the shell installer and the self-updater both refuse to hang, and the npm postinstall path — the one the GitHub Action uses — does not. That asymmetry looks like an oversight rather than a decision.
Reproduction
Black-hole the release host while installing:
# Accept the TCP connection, then never write.
sudo pfctl -e 2>/dev/null; # or a proxy that accepts and stalls
npm install -g @alibaba/open-code-reviewThe process prints Downloading <release-url> ... (scripts/install.js:202) and then hangs. In the action it hangs until GitHub's 360-minute job ceiling.
Expectation
A stalled connection is an error with a bounded wait, the way install.sh and update.js already treat it.
Fix shape
In download():
const req = https.get(url, {timeout: 20000}, (res) => { ... });
req.on("timeout", () => req.destroy(new Error(`Timed out fetching ${url}`)));
req.on("error", reject);and an inactivity watchdog on the piped body in downloadBinary, e.g. res.setTimeout(20000, () => res.destroy(new Error("stalled"))), falling into the existing res.on("error", ...) cleanup that already unlinks the partial file.
Note that the redirect path recurses through download(), so the fix has to apply per hop — the current code carries maxRedirects but not any timing state.
Environment
OpenCodeReview v1.14.2 (f6379f7), Node.js 20/22 via npm install.
How this was found
Reported by an automated multi-lens audit run (mini-ork) using four analysis models (glm, kimi, codex, minimax). I read scripts/install.js, scripts/update.js and install.sh at f6379f7 to confirm the missing guard and the two contrasts above. Not reproduced against a live stalled connection; the hang follows from the absence of any timeout path in the code.
Activity