Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random "LEVEL_DATABASE_NOT_OPEN" errors caused by "LEVEL_IO_ERROR" #245

Open
lucassilvas1 opened this issue Apr 20, 2024 · 0 comments
Open

Comments

@lucassilvas1
Copy link

lucassilvas1 commented Apr 20, 2024

I have a little NodeJS app that reads notification LevelDB databases of Chromium browsers. To do that, since it only needs read access, I copy the database to the project directory (./db to be specific), and use level to access it.
Since the purpose of the app is to watch for new notifications, I have a function checking the directory of the original database for changes. When a change is found, the app closes the level instance, deletes the copy database, makes a new copy and creates a new instance of level.

Now the problem is: seemingly randomly I'll get the error below when I call the open method of level:

C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\index.js:163
                throw new Error("Something went wrong while opening database", {
                      ^

Error: Something went wrong while opening database
    at #refresh (C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\index.js:163:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Retriever.retrieve (C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\index.js:178:9)
    at async onChange (C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\index.js:221:35) {
  [cause]: ModuleError: Database is not open
      at maybeOpened (C:\Users\Lucas\Javascript\chromium-notifier\node_modules\abstract-level\abstract-level.js:133:18)
      at C:\Users\Lucas\Javascript\chromium-notifier\node_modules\abstract-level\abstract-level.js:160:13
      at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
    code: 'LEVEL_DATABASE_NOT_OPEN',
    cause: [Error: IO error: RenameFile C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\db\36d5ce362e72a17b690f6cac0b40b70f/000091.dbtmp C:\Users\Lucas\Javascript\chromium-notifier\node_modules\chromium-notification-retriever\dist\db\36d5ce362e72a17b690f6cac0b40b70f/CURRENT: Access is denied.
    ] {
      code: 'LEVEL_IO_ERROR'
    }
  }
}

That error is thrown at this line here.
It says it can't rename some temp file because access is denied. I'm not sure why that would be when I'm sure Node has write access to that folder, and if you look at that file I linked above, the only times the "copy database" directory is interacted with is when there's no level instance open.
This is the only function that ends up interacting with the "copy database" directory, and it does so only after explicitly closing the instance, so I don't see how the files could be busy while trying to open the instance either.

I've been experiencing this intermittently for weeks now, and I have no idea what could be causing it, especially because the code is so simple, I've looked at it dozens of times by now.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant