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

byte length error when Deno upgraded to v1.31.2 #2

Closed
halparn opened this issue Mar 17, 2023 · 3 comments
Closed

byte length error when Deno upgraded to v1.31.2 #2

halparn opened this issue Mar 17, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@halparn
Copy link

halparn commented Mar 17, 2023

Hi, for a while i'm using btrdb databeses for simple data storage in Deno. After i upgrade Deno it's last version, and try to creating table and upsert some initial datas in it I encountered this error message:

error: Uncaught Error: Expect 16 == 19 throw new Error("Expect " + r.written + " == " + len); ^ at writeValue (https://deno.land/x/[email protected]/src/utils/binval.ts:75:13) at writeValue (https://deno.land/x/[email protected]/src/utils/binval.ts:107:9) at DocumentValue.writeTo (https://deno.land/x/[email protected]/src/utils/value.ts:141:5) at InFileStorage.addData (https://deno.land/x/[email protected]/src/pages/storage.ts:325:11) at async DbDocSet._set (https://deno.land/x/[email protected]/src/database/DbDocSet.ts:150:13) at async DbDocSet.upsert (https://deno.land/x/[email protected]/src/database/DbDocSet.ts:114:5)

Here is an example code how i offently upsert data usage:

const exampleWriteCode = async (dbpath, data) => {
  const db = new Database();
  await db.openFile(dbpath);
  const tbl = await db.createSet("tbl", "doc");
  await db.commit();

  for (let i = 0; i < data.length; i++) {
    const d = data[i];
    await tbl.upsert({ ...d });
  }

  await db.forceCommit();
};

After i encountered this error, downgraded deno to 1.31.1 fix this issue. This error produced v1.31.2 or later.

@halparn halparn changed the title byte length error when Deno upgraded in v1.31.2 byte length error when Deno upgraded to v1.31.2 Mar 17, 2023
@lideming lideming added the bug Something isn't working label Mar 17, 2023
@lideming lideming self-assigned this Mar 17, 2023
@lideming
Copy link
Owner

lideming commented Mar 17, 2023

Hi @halparn, thank you for reporting.
Unfortunately I can't reproduce this error. Could you provide a document object that could be the cause of this error?

@lideming
Copy link
Owner

It's a bug of TextEncoder.encodeInto() in Deno Runtime: denoland/deno#18255

@lideming
Copy link
Owner

lideming commented Apr 1, 2023

Fixed in denoland/deno#18518 and released in Deno v1.32.2

@lideming lideming closed this as completed Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants