You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// tested with Node.js v14.15.0
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');
db.serialize(function() {
//db.run("CREATE TABLE lorem (info TEXT)");
try {
db.run("INSERT INTO lorem VALUES (?)", [{toString: 23}])
} catch(e) {
console.log("caught exception")
}
});
db.close();
It seems like the V8 engine is erroring because it mistinterprets toString as a function.
Having looked at this deeper, many of the typecasts in statement.cc:BindParameters could technically fail, therefore it seems better to catch errors at a higher level. I've attempted to catch all errors of Bind but it doesn't seem to be throwing a C++ exception.
I've narrowed this specific case down to Statement:Bind() -> Statement:BindParameter() ->
else if (source.IsObject()) {
std::string val = source.ToString().Utf8Value();
return new Values::Text(pos, val.length(), val.c_str());
}
But I assume more calls in BindParameter could throw an exception.
The function Napi::String::Utf8Value raises an error, oddly enough it is part of the N-API code itself, so it should setup the error information for Napi::Error:New which throws a fatal abort because it can't retrieve the error information from napi_get_last_error_info.
I think we can enable C++ exceptions now after #1368 by removing the NAPI_DISABLE_CPP_EXCEPTIONS=1 define in binding.gyp. This will cause exceptions to bubble up properly and allow them to be handled.
@mohd-akram could you take a look at this please?
reproduce:
It seems like the V8 engine is erroring because it mistinterprets
toString
as a function.Having looked at this deeper, many of the typecasts in
statement.cc:BindParameters
could technically fail, therefore it seems better to catch errors at a higher level. I've attempted to catch all errors ofBind
but it doesn't seem to be throwing a C++ exception.I've narrowed this specific case down to
Statement:Bind()
->Statement:BindParameter()
->But I assume more calls in
BindParameter
could throw an exception.The function
Napi::String::Utf8Value
raises an error, oddly enough it is part of the N-API code itself, so it should setup the error information forNapi::Error:New
which throws a fatal abort because it can't retrieve the error information fromnapi_get_last_error_info
.stack trace:
The text was updated successfully, but these errors were encountered: