Giter VIP home page Giter VIP logo

Comments (5)

tndrle avatar tndrle commented on June 14, 2024

Hi, thanks for reporting this issue. Except for general advice, I cannot help much without a code example that reproduces the error, I'm afraid.

One thing you have to make sure though is that you need to finalize all prepared statements. Calling db.close() does not finalize pending prepared statements. To my understanding, neither sqlite3_close() nor sqlite3_close_v2() finalize pending statements (see Closing A Database Connection), so it makes no difference here. Notice that better-sqlite3 is garbage-collected and probably finalizes statements automatically, but node-sqlite3-wasm is not (at least not fully)!

In the library tests, I noticed that Windows (in contrast to macOS and Linux) is particularly picky about unfinalized statements. I don't know why. There is no Windows-specific code in node-sqlite3-wasm (except for the maximum path length).

Maybe that helps. If not, we really have to consider a code example, I guess.

from node-sqlite3-wasm.

dziudek avatar dziudek commented on June 14, 2024

Hi,

Thank you for more details - in fact we are using mainly get, run and all methods, which should be as documentation states automatically finalized. We are not using prepare at all in this case.

We are also using exec but only for DELETE operations, because for some reason delete queries are not working in our app on any platform (macOS, linux, Windows). But during my tests I was not running exec. To be sure - I have changed exec call to no-op operation in our DB abstraction layer - unfortunately without success :/

Maybe you will have some more ideas. I will also try to prepare some simple example, but I afraid that there is some more complex case here as with the delete statements, which are perfectly working in simple case, but not working in my case inside the app

from node-sqlite3-wasm.

dziudek avatar dziudek commented on June 14, 2024

Ok, finally I have found the issue :)

The problem is with the isOpen property - I have used this to check if I can safely close DB connection, because without it, when there is no connection, scripts throws an error.

When I have replaced my isOpen check with:

try {
   db.close();
} catch (e) {
   console.log('DB connection already closed');
} 

All is working fine :)

So I suppose that you should verify if the isOpen property works in all case. Unfortunately I cannot easily reproduce this issue on simple script - then isOpen seems to be working on Windows. But it is definitely a case, because after replacing all isOpen with try .. catch my problems are gone

from node-sqlite3-wasm.

tndrle avatar tndrle commented on June 14, 2024

Hi, thank you for all the details. To understand possible issues in the library better, I have two follow-up questions:

  1. How did you use isOpen? Like if (db.isOpen) { db.close() }?
  2. What problems do you have with DELETE statements? Did you try the run method, like db.run("DELETE ...")?

Thank you!

from node-sqlite3-wasm.

dziudek avatar dziudek commented on June 14, 2024

Hi,

  1. yes, exactly - in simple node.js script it was working, but in my app not

  2. yes - I have used db.run for DELETE statements and I always got 0 in changed rows amount. Similiar code on simple node.js script was working correctly. Changing db.run to db.exec solved the issue.

Maybe it is related somehow to used node.js version - electron uses v18, while my tests was on v16.

I am quite busy this week, but if I will find time, I will also try to reproduce this issues in simpler electron app to exclude other side effects

from node-sqlite3-wasm.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.