sqlite: add timeout options to DatabaseSync

PR-URL: https://github.com/nodejs/node/pull/57752
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Edy Silva authored and Antoine du Hamel committed 2025-05-19 12:14:07 +02:00
1 parent 8856712171
commit c12cd2a190
5 files changed
+112

No files matched your search

+19
View File
@@ -731,6 +731,8 @@ bool DatabaseSync::Open() {
CHECK_ERROR_OR_THROW(env()->isolate(), this, r, SQLITE_OK, false);
CHECK_EQ(foreign_keys_enabled, open_config_.get_enable_foreign_keys());
sqlite3_busy_timeout(connection_, open_config_.get_timeout());
if (allow_load_extension_) {
if (env()->permission()->enabled()) [[unlikely]] {
THROW_ERR_LOAD_SQLITE_EXTENSION(env(),
@@ -940,6 +942,23 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
}
allow_load_extension = allow_extension_v.As<Boolean>()->Value();
}
Local<Value> timeout_v;
if (!options->Get(env->context(), env->timeout_string())
.ToLocal(&timeout_v)) {
return;
}
if (!timeout_v->IsUndefined()) {
if (!timeout_v->IsInt32()) {
THROW_ERR_INVALID_ARG_TYPE(
env->isolate(),
"The \"options.timeout\" argument must be an integer.");
return;
}
open_config.set_timeout(timeout_v.As<Int32>()->Value());
}
}
new DatabaseSync(