Skip to content

fix: explain why the native addon failed to load - #14

Merged
AlexanderSlaa merged 1 commit into
mainfrom
fix/addon-load-error
Nov 21, 2026
Merged

AlexanderSlaa merged 1 commit into
mainfrom
fix/addon-load-error

Conversation

@AlexanderSlaa

Copy link
Copy Markdown
Contributor

What and why

When the native addon failed to load, the error said "Unable to load Ceph client libraries. Install librados2 and librbd1" whenever the failure message contained librados. The package's own install path (node_modules/node-librados/...) always contains it. So a missing or unbuilt addon file was reported as missing Ceph libraries, pointing people at the wrong fix.

Reproduced with the published 1.2.1 in node:24-bookworm-slim:

Real cause Old message cause
librados not installed Install librados2 and librbd1 ERR_DLOPEN_FAILED librados.so.2: cannot open shared object file
addon file missing Install librados2 and librbd1 (wrong) MODULE_NOT_FOUND Cannot find module '.../node-librados.node'

The load-error handling now lives in src-ts/load-error.ts and tells the failures apart:

Failure New message
Addon file missing (installed package) native addon is missing from the installed package (path). Reinstall node-librados; if that does not help, please report a bug.
Addon file missing (checkout) native addon is not built (path). Run npm run build:native.
Dynamic loader can't load librados.so.N / librbd.so.N Unable to load the Ceph client library librados.so.2. Install librados2 and librbd1 from Ceph Squid or Tentacle.
Anything else (wrong ELF class, undefined symbol) original error, unchanged

The new errors keep the original as cause.

How it was tested

  • New tests/unit/load-error.test.ts (3 tests) uses the exact error messages captured from the real failures above. It includes the case where librados appears only in the path, which the old check misreported.
  • The type check and the API coverage check pass.
  • Not done: putting the new loader into a real install and triggering both failures again (Docker was unavailable).

Checklist

  • npm run check passes
  • New behaviour has a test; a bug fix has a test that fails without the fix
  • New librados/librbd symbols are classified in coverage/api.json (none)
  • Operations on an IoContext use in_flight(state_) (not applicable)
  • README updated for user-visible changes (not needed)
  • Breaking changes are marked with ! in the title (none)

🤖 Generated with Claude Code

The loader reported "Install librados2 and librbd1" whenever the failure
message contained "librados", and the package path itself does
(node_modules/node-librados/...). So a missing or unbuilt addon file was
reported as missing Ceph libraries.

The loader now tells the failures apart:
- the addon file is missing: reinstall node-librados, or run
  "npm run build:native" in a checkout
- the dynamic loader cannot load librados.so.N or librbd.so.N: names that
  library and says to install librados2 and librbd1
- anything else (wrong ELF class, undefined symbols) is rethrown unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexanderSlaa
AlexanderSlaa merged commit e80d2f3 into main Nov 21, 2026
13 checks passed
@AlexanderSlaa
AlexanderSlaa deleted the fix/addon-load-error branch November 21, 2026 22:38
github-actions Bot pushed a commit that referenced this pull request Nov 21, 2026
## [1.2.3](v1.2.2...v1.2.3) (2026-11-21)

### Bug Fixes

* explain why the native addon failed to load ([#14](#14)) ([e80d2f3](e80d2f3))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant