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

more than one renderer create leveldb error #1

Closed
milu2003 opened this issue Oct 10, 2016 · 3 comments
Closed

more than one renderer create leveldb error #1

milu2003 opened this issue Oct 10, 2016 · 3 comments

Comments

@milu2003
Copy link

Hello, I recently used leveldb in electron.

I saw you were create leveldb in renderer.

If more than one renderer this will be a problem。

Do you have any solutions?

@cosmosgenius
Copy link
Owner

Two ways to solve this:

  • By opening leveldb in the main and use ipc to access leveldb in renderer.
  • Open and close leveldb before and after every operation respectively.

This was a test project to demonstrate electron-userland/electron-builder#647.

Probably I'll update the project to open leveldb in main.

@milu2003
Copy link
Author

milu2003 commented Oct 10, 2016

i just try opening in main. But there is a problem

use it in renderer:

`var rs = testdb.createReadStream(this.valueOps)

testdb.open();

rs.on('data' , function (data) {
   console.log(data.key, '=', data.value)

})
rs.on('error', function (err) {
    dlog(err);
})
rs.on('close', function () {
    dlog('关闭');
})
rs.on('end', function () {
    dlog('结束');
});
`

He did not execute the end callback

see my other issues:
Level/levelup#404

Although I closed the issues, but later found that there will still be a problem

You can test it on your project

@milu2003
Copy link
Author

I just close and open database when I was created.

Open and close leveldb before and after every operation respectively.

Maybe in accordance with what you said, each operation is closed open may be able to solve the problem

But is the price too high? Performance is very affected by it?

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

2 participants