CLI: close failure in main()'s finally becomes an unhandled rejection

Open Beginner friendly
#1,131 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
cli

Research direction

Start in bin/rocksdb-js.mjs and compare the main() cleanup path with the EPIPE handler, which already reports database close failures. Ensure a close failure goes through reportError with exit code 1 while readline cleanup still runs. Done when close failures use the normal CLI error format and readline closes; exercise the failure path if the project has a relevant CLI test.

Written by the indexing model from the issue text.

Description

CLI: a close failure in main()'s finally becomes an unhandled rejection

In bin/rocksdb-js.mjs, main() ends with finally { r?.close(); closeAllDatabases(); rl?.close(); }. If closeAllDatabases() throws (for example a failed close-time flush), the exception escapes the async main() and surfaces as an unhandled rejection. Node prints a raw stack trace, --json error formatting is skipped, and the exit code and message differ from every other CLI failure, which goes through reportError.

The EPIPE handler already guards the same call with try/catch plus reportError and exit code 1. The finally path should do the same, and rl?.close() should still run when the database close fails.

Found by the pre-push review of the fix for #1081 (CLI: deferred review nits from the #1055 follow-ups). It is pre-existing and outside that PR's diff. The fix is small, and the failure needs a close error to occur at all.

Review-Deferral: ae136b39fe3e7414 severity=nit category=reliability

🤖 Generated by Claude Code (Anthropic Claude Sonnet 5.5); posted via @cb1kenobi.

Dominant language
C++
Stars
24
Forks
3
Avg merge
1d 14h
Merged PRs (30d)
102

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HarperFast/rocksdb-js

All issues in HarperFast/rocksdb-js

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.