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

Data read, but end of buffer not reached #234

Open
anywhichway opened this issue May 20, 2023 · 6 comments
Open

Data read, but end of buffer not reached #234

anywhichway opened this issue May 20, 2023 · 6 comments

Comments

@anywhichway
Copy link

anywhichway commented May 20, 2023

I am occasionally getting Data read, but end of buffer not reached errors after a single putSync into a root database:

const id = db.putSync("Person@1",{
"name": "joe",
"age": 21,
"address": {
"city": "New York",
"state": "NY"
},
"created": "@Date(1684608677657)",
"aRegExp": "@regexp(/abc/)",
"unindexed": "unindexed",
"#": "Person@1"
})

 Data read, but end of buffer not reached 0

      425 |     if(keys.length===0 && scan) {
      426 |         const start = cname+"@";
    > 427 |         for(const entry of this.getRange({start})) {

However, db.get(id) works as expected.

I do not experience this with child databases.

I have been unable to create a simple example independent of the rest of my code. If I change the encoding type of json, then I get a parse error for an unexpected ,. Seems odd I should be able to read the object but not do a getRange.

@anywhichway
Copy link
Author

The error gets thrown on the last iteration across getRange. Some terminating character must not be getting written during a transaction. I have wrapped my code in a try/catch block for now and it works. However, it does make me a little nervous.

@kriszyp
Copy link
Owner

kriszyp commented May 21, 2023

Are you doing this in the root (null name) database and have child databases? Child databases are entries in the root database, and have a special LMDB encoding that throws this error when attempting to decode, so generally you can't have entries in the root database and child databases (if you are going to have child/named databases, best to keep all data in child/named databases).

@kriszyp
Copy link
Owner

kriszyp commented May 21, 2023

I realize this is a hazard and poorly documented, I will see if I can put some guardrails in place for this.

@anywhichway
Copy link
Author

anywhichway commented May 21, 2023 via email

@anywhichway
Copy link
Author

I have confirmed using another child and not the root fixes this. You can close if you wish, or leave open to drive the documentation/code updates you desire.

Let me know if you need a hand. I can fork and request a pull if necessary on the doc side of things.

@burrana-joshuaattlee
Copy link

Hey, I just came up against this exact issue. Would be good if the openDb documentation was updated to note this, and perhaps a Common Error FAQ added - also happy to fork because I think the 'encoder' option is missing from the typing?

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