Hi,
we recently started using node-bindgen in our project https://github.com/esrlabs/chipmunk and noticed the following:
Using a parameter with the type &str results in the compiler not complaining and building completely fine. As soon as the function is called on the Javascript side, a huge error log is being printed from which it is hard to tell what the actual issue is.
The following code shows a minimal example of the issue:
// lib.rs
use node_bindgen::derive::node_bindgen;
#[node_bindgen]
fn hi(name: &str) {
println!("Hello {}", name);
}
// main.js
let addon = require("../dist");
addon.hi("Hello");
Running the main.js file results in the following error log:
$ node main.js
[4556]: c:\ws\src\node_buffer.cc:246: Assertion `val->IsArrayBufferView()' failed.
1: 00007FF69DDB013F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112495
2: 00007FF69DD3F396 DSA_meth_get_flags+65526
3: 00007FF69DD3F751 DSA_meth_get_flags+66481
4: 00007FF69DD60F28 node::Buffer::Data+168
5: 00007FF69DD7004F napi_get_buffer_info+79
6: 00007FF905A53119 nj_core::convert::impl$17::convert_to_rust+137 [C:\Users\Pepe\.cargo\registry\src\github.com-1ecc6299db9ec823\nj-core-4.3.0\src\convert.rs]:L239
7: 00007FF905A510B7 nj_core::basic::impl$12::convert_arg_at<str>+183 [C:\Users\Pepe\.cargo\registry\src\github.com-1ecc6299db9ec823\nj-core-4.3.0\src\basic.rs]:L816
8: 00007FF905A512BA nj_core::basic::JsCallback::get_value_at<str>+186 [C:\Users\Pepe\.cargo\registry\src\github.com-1ecc6299db9ec823\nj-core-4.3.0\src\basic.rs]:L688
9: 00007FF905A5187A something::napi_hi::closure$0+202 [C:\Users\Pepe\Desktop\Something\src\lib.rs]:L3
10: 00007FF905A513FC something::napi_hi+76 [C:\Users\Pepe\Desktop\Something\src\lib.rs]:L3
11: 00007FF69DD7E7C7 node::Stop+36391
12: 00007FF69E62C3B6 v8::internal::Builtins::code_handle+172694
13: 00007FF69E62BFA9 v8::internal::Builtins::code_handle+171657
14: 00007FF69E62C26C v8::internal::Builtins::code_handle+172364
15: 00007FF69E62C0D0 v8::internal::Builtins::code_handle+171952
16: 00007FF69E6FF4E1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
17: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
18: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
19: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
20: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
21: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
22: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
23: 00007FF69E69198E v8::internal::SetupIsolateDelegate::SetupHeap+45310
24: 00007FF69E68FB9C v8::internal::SetupIsolateDelegate::SetupHeap+37644
25: 00007FF69E68F79B v8::internal::SetupIsolateDelegate::SetupHeap+36619
26: 00007FF69E570471 v8::internal::Execution::CallWasm+1521
27: 00007FF69E56FD5F v8::internal::Execution::Call+191
28: 00007FF69E652DFC v8::Function::Call+508
29: 00007FF69DD7166E node_api_get_module_file_name+3038
30: 00007FF69DD752B7 node::Start+983
31: 00007FF69DD75668 node::Start+1928
32: 00007FF69DDDC099 node::LoadEnvironment+89
33: 00007FF69DCF7AB3 cppgc::internal::NormalPageSpace::linear_allocation_buffer+53811
34: 00007FF69DD74FBD node::Start+221
35: 00007FF69DB988CC RC4_options+348108
36: 00007FF69EBF08F8 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+14472
37: 00007FF950517034 BaseThreadInitThunk+20
38: 00007FF952502651 RtlUserThreadStart+33
It took me many hours to figure out where the problem was. I guess it would make sense to point to this error during the build to avoid other users getting stuck on this kind of error.
Hi,
we recently started using
node-bindgenin our project https://github.com/esrlabs/chipmunk and noticed the following:Using a parameter with the type
&strresults in the compiler not complaining and building completely fine. As soon as the function is called on the Javascript side, a huge error log is being printed from which it is hard to tell what the actual issue is.The following code shows a minimal example of the issue:
Running the
main.jsfile results in the following error log:It took me many hours to figure out where the problem was. I guess it would make sense to point to this error during the build to avoid other users getting stuck on this kind of error.