louischatriot / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
13.46k stars 1.03k forks source link

nedb indexeddb dont get created on electron dev-server... sometimes #657

Closed Macster87 closed 2 years ago

Macster87 commented 3 years ago

Hi everyone. This is an odd issue and i dont know whats wrong or how to solve it.

I have an Vue+Electron project. I use NeDB inside electron, so its storing all the data in IndexedDB which usually works fine. I just initialize my 4 collections like this:

let db = {
    customers: new Datastore({ filename: "customers", autoload: true }),
    nodes: new Datastore({ filename: "nodes", autoload: true }),
    channels: new Datastore({ filename: "channels", autoload: true }),
    measurements: new Datastore({ filename: "measurements", autoload: true }),
}

The collections get created inside IndexedDB and i can interact with the database, everything works fine.

Screenshot 2020-10-19 at 10 19 59

Until recently when on my computer at work NeDB stopped working. The database wont load. The IndexedDB still had entries but its ignored. If i wipe the database, NeDB should recreate the collections but it doesnt. IndexedDB stays empty. The most confusing thing: No error messages, nothing.

electron_MjVUYhrpW2

But the same code worked on my homeoffice computer until today and it suddenly stopped working too. Now my macbook is the only computer where the code runs as expected.

I tried manual loading of the database but the method doesnt seem to be called at all.

db.nodes.loadDatabase(function(err) {
    if (err) {
        console.log(err)
    }
    console.log("Nodes loaded")
})

I also tried deleting the app cache under %APPDATA%, but no difference.

If i build my app for production, the database is suddenly working again as expected. So i havent seen this issue in production yet. I just dont know whats wrong here and because there are no error-messages whatsoever i really dont know how to fix this.