-
Notifications
You must be signed in to change notification settings - Fork 434
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
MultiHeadAttention::new() and RuvectorLayer::new() in ruvector-gnn use assert!() / panic!() for input validation instead of returning Result. When called from NAPI-RS or WASM bindings, this causes a fatal abort() that crashes the entire host process — no try/catch can intercept it.
Reproduction
const { RuvectorLayer } = require('@ruvector/gnn');
// This kills the process — no exception, just abort()
const layer = new RuvectorLayer(384, 128, 3, 0.1);
// hidden_dim=128 is NOT divisible by heads=3 → panicthread '<unnamed>' panicked at crates/ruvector-gnn/src/layer.rs:97:9:
Embedding dimension must be divisible by number of heads
fatal runtime error: failed to initiate panic, error 5, aborting
Aborted (core dumped)
Root Cause
Two issues:
- Rust-side (
crates/ruvector-gnn/src/layer.rs):MultiHeadAttention::new()usesassert!()instead ofResult— panics across FFI boundary = process abort - JS-side (downstream
agentdbGNNService): passesconfig.layers(=3) as theheadsparameter instead ofconfig.heads, so128 % 3 ≠ 0triggers the panic
Fix
MultiHeadAttention::new()→ returnsResult<Self, GnnError>RuvectorLayer::new()→ returnsResult<Self, GnnError>- All WASM/NAPI wrappers propagate errors as catchable JS exceptions
- Also fixed pre-existing
mmap.rstest compilation errors (grad_offset returnsOption<usize>)
Affected Versions
@ruvector/gnn@0.1.24(all platforms)ruvector-gnn(Rust crate)
Impact
| Surface | Before | After |
|---|---|---|
| Native Rust | panic!() → process abort |
Err(GnnError::LayerConfig(...)) |
| NAPI-RS (Node.js) | abort() → uncatchable crash |
Catchable napi::Error |
| WASM | WASM trap | Catchable JsError |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working