question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Failed to convert rust `String` into napi `string`

See original GitHub issue

Bug description

I’m trying to query a big amount of data that fails, because of some unknown error.

I was only able to find the issue #13192 to be related on this matter.

Full error message:

"stack": "Error: Failed to convert rust `String` into napi `string`
 at RequestHandler.request (/app/node_modules/@prisma/client/runtime/index.js:49022:15)
 at async /app/build/services/data.service.js:8:20
 at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:49919:18)
 at async getData (/app/build/services/data.service.js:16:25)
 at async basicStatisticsController (/app/build/controllers/statistics/index.js:16:48)"

How to reproduce

I’m not exactly sure, the error occurs only when I’m querying data that is huge in size, aka somewhere between ~500 MB

Expected behavior

No response

Prisma information

query looks like this:

    await prisma.table.findMany({
      where: {
        dateTime: {
          gte: date.start,
          lte: date.end,
        },
      },
    });
    
    // Same error when using the queryRaw like this:
    await prisma.$queryRaw`
      SELECT * FROM "Table"
      WHERE "dateTime" BETWEEN ${date.start} AND ${date.end}
    `;

Environment & setup

  • OS: Windows/Linux
  • Database: PostgreSQL
  • Node.js version: 16.3
  • DB Hosted on: AWS Aurora

Prisma Version

Happens on 3.15.2 as well as 3.14

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:10
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Quesstorcommented, Nov 12, 2022

Alright, i coded a reproduction example. You can find it at https://github.com/Quesstor/prisma-error

I had to make a few test to boil the problem down. The JSON contains a very long string property (>500kb) and you have to select a certain amount of rows (in my case it worked with 1066 rows and breaks with the 1067th one).

You can run the example by cloning the repo and simply run docker compose up. The docker compose includes the postgres DB and the example app.

2reactions
sunneydevcommented, Aug 18, 2022

@sunneydev ooh, could you elaborate please? I’ll try with a few different chunk sizes. Would be helpful to know since the patch right now is to run the operation in batches, so this info would at least help with knowing what a safe batch size is.

There’s a hard-coded string size limit in the V8 engine (JS engine that Node.js relies on). My thoughts are it might be related to that. It’s somewhere between 256 MB - 1 GB. I don’t know exactly.

This stack overflow issue might be useful

Read more comments on GitHub >

github_iconTop Results From Across the Web

string.rs - source - SWC
... "Failed to convert rust `String` into napi `string`" )?; Ok(ptr) } } impl ... env, napi_val, "Failed to convert napi `{}` into...
Read more >
I am getting and error Failed to convert rust String into na | Orm-help ...
I am getting and error Failed to convert rust String into napi string Seems ... It happens with same query but only when...
Read more >
Error in napi - Rust - Docs.rs
Represent `JsError`. Return this Error in `js_function`, napi-rs will throw it as `JsError` for you. If you want throw it as `TypeError` or...
Read more >
How to convert a String into a &'static str - rust - Stack Overflow
Sometime, the original string doesn't live enough, like in a match {...} block. That will lead to a 's' does not live long...
Read more >
napi – NAPI-RS
You can use the ClassInstance as Object on the Rust side and manipulate it. ... #[napi] impl JsRepo { #[napi(constructor)] pub fn new(dir:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found