Release builds abort the process when an internal native assert fails

Open
#1,113 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@cb1kenobi is already working on this.

Since Nov 18, 2026.

  • #1115 by @cb1kenobi — open

Assessment

This issue has not been assessed yet.

Description

bug

Problem

The native binding has seven bare assert() calls, and binding.gyp's Release configuration never defines NDEBUG, so all of them are compiled into the release builds we publish. Their message strings are present in the published @harperfast/[email protected] binary.

If one fires, assert() calls abort(): the host process (Node, Harper) dies with SIGABRT. There is no JS error, no log line from our code, and no chance to recover. Each condition is an internal invariant, not something a caller can provoke, and none has been observed firing, but a broken invariant in any of them takes down the whole process rather than the one operation.

Site (as of 043141a1) Condition What a violation actually means
napi/async.h:45 asyncWork == nullptr in ~BaseAsyncState the async work leaks
transaction/transaction.cpp:778 Committing → Committed transition succeeded close() aborted the handle concurrently; the RocksDB commit itself succeeded
transaction/transaction_handle.cpp:347, :449 iterator registered once benign
transaction/transaction_handle.cpp:363, :530 activeIteratorCount did not underflow the uint32_t wraps and the orphan close never runs
transaction/transaction_handle.h:65 InlineVector::back() on a non-empty vector an out-of-bounds read

Only the last one cannot safely continue; the rest are better reported and survived than turned into a process abort.

Proposed fix

  • A Node-free ROCKSDB_JS_ASSERT(condition, message) in src/binding/core/. It is fatal (report, then std::abort()) in DEBUG builds and when a new ROCKSDB_JS_FATAL_ASSERTS define is set. Otherwise it writes one warning line to stderr per call site and continues. It is noexcept, takes no locks, and makes no N-API or getenv calls, because it runs on RocksDB, commit and libuv threads and in destructors.
  • Replace every bare assert(). Make InlineVector's empty read impossible rather than asserted.
  • Set ROCKSDB_JS_FATAL_ASSERTS in the PR test workflow so CI still fails loudly, and keep it out of the publish workflow that builds the shipped prebuilds.
  • Document the rule in AGENTS.md and add a check that rejects a new bare assert( in src/binding.

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

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

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.