Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.49k stars 589 forks source link

In a Node.js environment, throws a resource lock error. #1705

Open KotoriMinami opened 10 months ago

KotoriMinami commented 10 months ago

My basic code is as follows.

import { mySchema } from './model/schema.js'

import SQLiteAdapter from "@nozbe/watermelondb/adapters/sqlite/index.js";

const adapter = new SQLiteAdapter({
    dbName: 'test',
    schema: mySchema,
    onSetUpError: error => {
        // Database failed to load -- offer the user to reload the app or log out
        console.log(error)
    }
})

At this point, running the code produces the following results. image How should it be handled?

GitMurf commented 1 week ago

@KotoriMinami I am having this exact same issue. It looks like from the stack trace in your image that you are on Windows? I am on Windows as well.

See https://github.com/Nozbe/WatermelonDB/issues/1810#issuecomment-2351020396 for details on my issues.

KotoriMinami commented 1 week ago

@GitMurf Yes, I encountered this issue on Windows, but it's completely fine on Mac. I resolved it by applying the PR's code locally on my machine, and it's been running for about a year without any significant issues. I'm not sure if your issue is the same as mine, but you can give it a try and see if it solves your problem.

GitMurf commented 1 week ago

I resolved it by applying the PR's code locally on my machine,

and it's been running for about a year without any significant issues.

Thanks! And to be clear, all it needs are these 3 lines added from here: https://github.com/Nozbe/WatermelonDB/commit/59f87f171550920beb2941cdf5f33a43577d2915 ?!!

KotoriMinami commented 1 week ago

I resolved it by applying the PR's code locally on my machine, and it's been running for about a year without any significant issues.

Thanks! And to be clear, all it needs are these 3 lines added from here: 59f87f1 ?!!

Yes, that's exactly how I did it.