Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] - NAPI Fatal Errors #1381

Closed
akazakou opened this issue Sep 14, 2020 · 12 comments
Closed

[email protected] - NAPI Fatal Errors #1381

akazakou opened this issue Sep 14, 2020 · 12 comments

Comments

@akazakou
Copy link

Got an error for [email protected]. My code using sqlite3 in worker_threads with massive read operations. Database stored in memory.

"sqlite3": {
  "version": "5.0.0",
  "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.0.0.tgz",
  "integrity": "sha512-rjvqHFUaSGnzxDy2AHCwhHy6Zp6MNJzCPGYju4kD8yi6bze4d1/zMTg6C7JI49b7/EM7jKMTvyfN/4ylBKdwfw==",
  "requires": {
    "node-addon-api": "2.0.0",
    "node-gyp": "3.x",
    "node-pre-gyp": "^0.11.0"
  }
},
FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw
 1: 0x9fd5f0 node::Abort() [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 2: 0x94a45d node::FatalError(char const*, char const*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 3: 0x94a466  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 4: 0x9cfc7b napi_fatal_error [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 5: 0x7fa1e40482fd  [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 6: 0x7fa1e4049763 Napi::Error::ThrowAsJavaScriptException() const [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 7: 0x7fa1e405f206 node_sqlite3::Statement::Statement(Napi::CallbackInfo const&) [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 8: 0x7fa1e406d446 Napi::ObjectWrap<node_sqlite3::Statement>::ConstructorCallbackWrapper(napi_env__*, napi_callback_info__*)::{lambda()#1}::operator()() const [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 9: 0x7fa1e406cd5e Napi::ObjectWrap<node_sqlite3::Statement>::ConstructorCallbackWrapper(napi_env__*, napi_callback_info__*) [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
10: 0x9b40df  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
11: 0xbdd915  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
12: 0xbddf1f  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
13: 0xbde546 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
14: 0x13cc9d9  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
@akazakou
Copy link
Author

akazakou commented Sep 14, 2020

Additional error

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
 1: 0x9fd5f0 node::Abort() [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 2: 0x94a45d node::FatalError(char const*, char const*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 3: 0xb706ba v8::Utils::ReportApiFailure(char const*, char const*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 4: 0xcdcdf2 v8::internal::HandleScope::Extend(v8::internal::Isolate*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 5: 0xb720d1 v8::HandleScope::CreateHandle(v8::internal::Isolate*, unsigned long) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 6: 0x9bb045 napi_get_reference_value [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
 7: 0x7fe5adbe4286 Napi::Reference<Napi::Function>::Value() const [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 8: 0x7fe5adbe47f5 node_sqlite3::Database::HasInstance(Napi::Value) [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
 9: 0x7fe5adbfa1af node_sqlite3::Statement::Statement(Napi::CallbackInfo const&) [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
10: 0x7fe5adc08446 Napi::ObjectWrap<node_sqlite3::Statement>::ConstructorCallbackWrapper(napi_env__*, napi_callback_info__*)::{lambda()#1}::operator()() const [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
11: 0x7fe5adc07d5e Napi::ObjectWrap<node_sqlite3::Statement>::ConstructorCallbackWrapper(napi_env__*, napi_callback_info__*) [/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node]
12: 0x9b40df  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
13: 0xbdd915  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
14: 0xbddf1f  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
15: 0xbde546 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]
16: 0x13cc9d9  [/home/nodejs/.nvm/versions/node/v14.7.0/bin/node]

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

@akazakou
Copy link
Author

akazakou commented Sep 14, 2020

Attached fatal error report
report.20200914.153842.32355.0.001.zip

Fatal errors triggered only in case of usage sqlite3 in worker_threads. If we using sqlite3 from the main thread - application working stable

@akazakou akazakou changed the title FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw [email protected] - FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw Sep 15, 2020
@akazakou akazakou changed the title [email protected] - FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw [email protected] - NAPI fatal errors Sep 15, 2020
@akazakou akazakou changed the title [email protected] - NAPI fatal errors [email protected] - NAPI Fatal Errors Sep 15, 2020
@BubuAnabelas
Copy link

I'm having the same errors, I've also tried installing [email protected] with the --build-from-source flag but the issue persists.
The error only appears when runing a query in a worker thread.

@jfberry
Copy link

jfberry commented Feb 26, 2021

Same error with [email protected]

@Nguyenhongphuc98
Copy link

nodejs: v15.6.0
sqlite3: v5.0.2

When runing sqlite query in one worker thread is okay.
const worker = new Worker('./worker.js', { workerData: opts });
But for if more than one worker thread cause the same error.
const worker2 = new Worker('./worker.js', { workerData: opts });

@vishalkrishnads
Copy link

This isn't just present with worker threads. This throws the same error even if the query is run from the main thread.

if(isMainThread){
    worker.on('exit', ()=>{
        db.serialize(() => {
            db.each(`SELECT sellers as sellers,
                            results as no_of_results
                     FROM maps WHERE category = ?`, [category], (err, row) => {
                if (err) {
                    console.log(err);
                }
                console.log(row.sellers + "\t" + row.no_of_results);
            });
        });
    })
}

This also throws the same error mentioned by @akazakou.... #1367 says that it fixes this. But we're still getting the same error...

@ax-vasquez
Copy link

ax-vasquez commented May 11, 2021

I've hit this in both 5.0.0 and 5.0.2. Fortunately, in my project, I am able to downgrade without issue; I'm now using 4.2.0 and no longer hit the issue.

I'll be sure to keep tabs on this so I can update when it's fixed! 👍

@cirosantilli
Copy link

Another related issue: #1223

better-sqlite3 claims to have implemented at: WiseLibs/better-sqlite3#237 BTW

@Derp33
Copy link

Derp33 commented Feb 3, 2022

Could be unrelated but just had similar problems in my electron 17.0.0 app.
The solution for me was ensuring to close the db connection before the worker_thread exits.

@daniellockyer
Copy link
Member

Would you be able to try with v5.0.3? 🙂

@jaytist
Copy link

jaytist commented May 20, 2022

I am getting this while using node 14.9.2. Do we have any solution?

Here is the stack trace

FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw
 1: 0xa3aaf0 node::Abort() [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
 2: 0x970199 node::FatalError(char const*, char const*) [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
 3: 0x9701a2  [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
 4: 0xa07ddb napi_fatal_error [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
 5: 0x7fae8ca3c3de  [/home/runner/work/keyv/keyv/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node]
 6: 0x7fae8ca3ca92 Napi::Error::ThrowAsJavaScriptException() const [/home/runner/work/keyv/keyv/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node]
 7: 0x7fae8ca3d017 Napi::Function::MakeCallback(napi_value__*, unsigned long, napi_value__* const*, napi_async_context__*) const [/home/runner/work/keyv/keyv/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node]
 8: 0x7fae8ca59e40 node_sqlite3::Statement::Work_AfterAll(napi_env__*, napi_status, void*) [/home/runner/work/keyv/keyv/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node]
 9: 0xa0a329 node::ThreadPoolWork::ScheduleWork()::{lambda(uv_work_s*, int)#2}::_FUN(uv_work_s*, int) [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
10: 0x13bc2fd  [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
11: 0x13c0a86  [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
12: 0x13d2ff4  [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
13: 0x13c13d8 uv_run [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
14: 0x9d1428 node::Environment::CleanupHandles() [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
15: 0x9d6b56 node::Environment::RunCleanup() [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
16: 0x9917f7 node::FreeEnvironment(node::Environment*) [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
17: 0xafd4af node::worker::Worker::Run() [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
18: 0xafd6f8  [/opt/hostedtoolcache/node/14.19.2/x64/bin/node]
19: 0x7fae9721e[609](https://github.com/jaredwray/keyv/runs/6500107069?check_suite_focus=true#step:6:610)  [/lib/x86_64-linux-gnu/libpthread.so.0]
20: 0x7fae97143163 clone [/lib/x86_64-linux-gnu/libc.so.6]

@imtiazShakil
Copy link

the problem happens with v5.1.6 using node v18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests