You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
node:events:513
const handler = events[type];
^
TypeError: Cannot read properties of null (reading 'close')
at Database.emit (node:events:513:25)
The value of db is
Steps to Reproduce
// see below for how I defined the sqlite_* functions// they're basically promisified versions of open/serialize/closeconstdb=awaitsqlite_open("../feeds.sqlite");awaitsqlite_serialize({db: db,statements: [...]});awaitsqlite_close(db);exportasyncfunctionsqlite_open(filename: string): Promise<sqlite3.Database>{returnawaitnewPromise<sqlite3.Database>((resolve,reject)=>{constdb=newsqlite3.Database(filename,(err)=>{if(err){reject(err);}else{resolve(db);}});});}exportasyncfunctionsqlite_close(db: sqlite3.Database): Promise<{}>{returnawaitnewPromise<{}>((resolve,reject)=>{debugger;db.close((err)=>{if(err){reject(err);}else{resolve({});}});});}exportasyncfunctionsqlite_serialize({
db,
statements,}: {db: sqlite3.Database;statements: string[];}): Promise<{}>{constpromises: Promise<{}>[]=[];db.serialize(()=>{for(conststatementofstatements){console.info(statement);promises.push(newPromise<{}>((resolve,reject)=>{db.run(statement,[],(err)=>{if(err){reject(err);}else{resolve({});}});}));}});awaitPromise.all(promises);return{};}
Version
5.1.7
Node.js Version
18.20.4
How did you install the library?
yarn add sqlite3
The text was updated successfully, but these errors were encountered:
The issue seems to go away if I instead of giving a callback to open I use db.once to wait for the database to be correctly opened (in which case, _events is notnull)
Issue Summary
When I call
I get the error:
The value of
db
isSteps to Reproduce
Version
5.1.7
Node.js Version
18.20.4
How did you install the library?
yarn add sqlite3
The text was updated successfully, but these errors were encountered: