Comments (5)
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.
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.
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.
Hi, thank you for all the details. To understand possible issues in the library better, I have two follow-up questions:
- How did you use
isOpen
? Likeif (db.isOpen) { db.close() }
? - What problems do you have with
DELETE
statements? Did you try therun
method, likedb.run("DELETE ...")
?
Thank you!
from node-sqlite3-wasm.
Hi,
-
yes, exactly - in simple node.js script it was working, but in my app not
-
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)
- Question: Does the SQLite3 needs to be installed on target PC? And what about pragmas? HOT 1
- Question. Is there an ESM version. HOT 4
- node-sqlite3-wasm.d.ts missing HOT 3
- knex support?
- failed to compile wasm module: RangeError: WebAssembly.Compile is disallowed on the main thread HOT 2
- Table index is out of bounds error HOT 2
- Generator/iterator method HOT 3
- Include FTS5 extension HOT 1
- [feature request] add support for `returing` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlite3-wasm.