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

segfault when path set to null or undefined (typescript demands path to exist) #243

Open
timotejroiko opened this issue Jun 20, 2023 · 3 comments

Comments

@timotejroiko
Copy link

Hello,

According to documentation, omitting the path parameter during db.open() should create a temporary database that automatically deletes itself. However Typescript erroneously claims that path is a required parameter and cannot be omitted.

Furthermore, any attempt to make path behave as if omitted by setting it to null or undefined causes a segfault.

Not a high priority issue, but we could improve QOL here by both updating the typings to mark path as optional as well as preventing null/undefined path from segfaulting and make it behave as if it were omitted.

Thanks!

@kriszyp
Copy link
Owner

kriszyp commented Jun 21, 2023

I can update the typings, but I can't reproduce any segfault when omitting the path (in fact the unit tests extensively use databases opened without a path so that can run on temp databases). Do you have any steps to reproduce this?

@timotejroiko
Copy link
Author

Hey, thanks for the reply.

For me it happens on node 20.3.0 on windows when you explicitly set path to a falsey value, for example { path: "" } or { path: null } or { path: undefined }. It works correctly if explicitly omitted like this {}

Using lmdb v2.8.2

kriszyp added a commit that referenced this issue Jun 23, 2023
kriszyp added a commit that referenced this issue Jul 28, 2023
@alexghr
Copy link

alexghr commented Nov 22, 2023

Hey, just to add to this: I've been using 2.9.1 and the typescript declarations seems to be different between ES and CJS files. index.d.cts has path as a required key in RootDatabaseOptionsWithPath while index.d.ts lists path as optional. As a result ts-jest fails to compile tests that are using temporary lmdb databases (there's a bug in ts-jest where it prefers .d.cts files over .d.ts or .d.mts kulshekhar/ts-jest#4221)

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

3 participants