Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

sqlite3@5.0.0 - NAPI Fatal Errors #1381

Description

@akazakou

Got an error for sqlite3@5.0.0. 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]

Activity

  1. akazakou commented on Sep 14, 2020

    @akazakou
    Author

    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)
    
  2. akazakou commented on Sep 14, 2020

    @akazakou
    Author

    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

  3. changed the title [-]FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw[/-] [+]sqlite3@5.0.0 - FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw[/+] on Sep 15, 2020
  4. changed the title [-]sqlite3@5.0.0 - FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw[/-] [+]sqlite3@5.0.0 - NAPI fatal errors[/+] on Sep 15, 2020
  5. changed the title [-]sqlite3@5.0.0 - NAPI fatal errors[/-] [+]sqlite3@5.0.0 - NAPI Fatal Errors[/+] on Sep 15, 2020
  6. BubuAnabelas commented on Dec 7, 2020

    @BubuAnabelas

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

  7. jfberry commented on Feb 26, 2021

    @jfberry

    Same error with sqlite3@5.0.2

  8. Nguyenhongphuc98 commented on Mar 12, 2021

    @Nguyenhongphuc98

    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 });

  9. vishalkrishnads commented on Mar 14, 2021

    @vishalkrishnads

    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...

  10. ax-vasquez commented on May 11, 2021

    @ax-vasquez

    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! 👍

  11. cirosantilli commented on Nov 4, 2021

    @cirosantilli

    Another related issue: #1223

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

  12. Derp33 commented on Feb 3, 2022

    @Derp33

    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.

  13. daniellockyer commented on Apr 15, 2022

    @daniellockyer
    Contributor

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

  14. stropicall commented on May 20, 2022

    @stropicall

    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]
    
  15. imtiazShakil commented on Aug 26, 2024

    @imtiazShakil

    the problem happens with v5.1.6 using node v18

  16. added a commit that references this issue on Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions