matrix-org / matrix-org/matrix-rust-sdk-crypto-nodejs
download-lib.js: catch (ex) block calls console.error(err) (ReferenceError), masking the real download error
- Dominant language
- Rust
- Stars
- 11
- Forks
- 23
- Avg merge
- 22h 12m
- Merged PRs (30d)
- 1
Description
Bug Description
In download-lib.js, the catch block wrapping dl.start() references an undefined variable:
} catch (ex) {
console.error(err);
process.exit(1);
}
err is not defined in that scope (the parameter is ex), so whenever the download rejects, the script crashes with ReferenceError: err is not defined instead of printing the actual error. The other catch block in the same file uses console.error(ex) correctly, so this looks like a copy/paste slip. Present in @matrix-org/matrix-sdk-crypto-nodejs@0.6.6 and still on main (lines 82-83).
Impact
When the prebuilt binary download fails for any reason (network, CDN abort, TLS, proxy), pnpm install fails with only:
ReferenceError: err is not defined
at download_lib (download-lib.js:83:23)
The real cause is completely hidden, which makes install failures very hard to diagnose. In our case the underlying error was a mid-transfer socket abort against the GitHub release-assets CDN; we only discovered it by patching this line locally to console.error(ex).
Steps to Reproduce
- Make the binary download fail (e.g. block the download URL) and install any package running this postinstall, e.g.
npm i @matrix-org/matrix-sdk-crypto-nodejs@0.6.6 - Observe the failure output: only the ReferenceError above, no mention of the actual download error
Expected Behavior
The original download error is reported (e.g. console.error(ex)), not replaced by an unrelated ReferenceError.
Environment
- Package:
@matrix-org/matrix-sdk-crypto-nodejs0.6.6 (also unfixed onmain) - OS: Linux x64 (Ubuntu 24.04), Node v26.8.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in download-lib.js around lines 82-83 and compare the catch block wrapping dl.start() with the other catch block in the same file. Reproduce a failed binary download during installation, then verify that the original download error is reported instead of a ReferenceError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100