-
Notifications
You must be signed in to change notification settings - Fork 44
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
LMDB on Electron renderer #278
Comments
Update: I got it working! It turns out that this library works fine with Webpack and doesn't really require any special treatment! So I removed The only thing I need to modify is that // Enable SharedArrayBuffer
// https://stackoverflow.com/a/74623813/622510
browserWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
details.responseHeaders['Cross-Origin-Opener-Policy'] = ['same-origin'];
// Needs to set `Cross-Origin-Embedder-Policy ` to `credentialless` so that images from other sources
// can be loaded.
// https://github.com/ffmpegwasm/react-app/issues/3#issuecomment-1016234599
details.responseHeaders['Cross-Origin-Embedder-Policy'] = ['credentialless'];
callback({ responseHeaders: details.responseHeaders });
}) And now I can access the database from the renderer process. Thanks a lot for the library! I do have another question: is it possible to access the same database from multiple renderer process? Or should I only access the DB from one process, and use |
Update: unfortunately, changing response header for all requests causes many security issues, so I have to patch However, is it safe to do so, if I only use LMDB in one main thread and does not access the DB elsewhere? Thank you! |
Yes, LMDB is designed to support multi-process access to the same database, and handles locking between processes.
Yes, that should be safe to do. lmdb-js doesn't actually share the buffers between different JS worker threads, there is only shared access with the native C threads, and I don't believe SharedArrayBuffer and ArrayBuffer differ at all with respect to that, they just have different interfaces/functionality that they support (which varies across platform and version in rather unpredictable ways), and the important functionality is access to the When you say that |
Yes, the global variable
|
I can confirm version 3.0.0 works fine, thank's for fixing :) |
Hi,
I've tried to integrate this library into our Electron app and want to use LMDB on the renderer process. However when I import the library
import { open } from 'lmdb'
, I found the error below:TypeError: The URL must be of scheme file
I guess the error is from the
native.js
file:My project uses Webpack to bundle JS files, and have set
lmdb
asexternals
in thewebpack.config.js
file, so that Webpack treats the module as external module and doesn't try to bundle it.I wonder is there any other way to detect the
dirName
or work around this issue? I've tried to logimport.meta.url
and found it starts with schemefile://
:file:///Users/username/project/home/src/renderer/main.js
, so I don't really know why the error aboutThe URL must be of scheme file
.Thank you.
The text was updated successfully, but these errors were encountered: