Skip to content

[bug] Failed to convert rust String into napi string on "large" installs #360

Open
@24601

Description

@24601

Describe the bug

In "large" installations (e.g. an amount of repos resulting in ostensibly a "large" enough dataset to occupy available memory and/or hit certain performance limits, not fully sure all the drivers to this failure pathology here yet and not sure it matters, see below), when doing large queries, Sourcebot becomes unresponsive/very slow and this message continually (infinitely) is displayed on the console, and Sourcebot is basically inoperable (the UI also shows 0 repos despite over 20,000 having been indexed).

I suspect the root cause is a known error in Prisma (prisma/prisma#13864) that ostensibly will be fixed soon, but this is only an issue I believe because there is an unbounded prisma.repo.findMany() call in one or more codepaths that should be paginated and/or use a cursor, because this always results in full use of the allocated memory to the Sourcebot instance, which very much fits the pathology of "load everything into memory rather than paginate or cursor seek" that the Prisma bug reference is also symptomatic of.

Prisma has not yet fixed this (although it seems to be coming), however, I think the actual fix might be to ensure that calls to findMany() are paginated with sane sizes (perhaps even parallelized to an appropriate configurable limit for performance?) and/or are modified to use cursor-driven seek/streaming.

[web] | Failed to convert rust String into napi string
[web] | PrismaClientKnownRequestError:
[web] | Invalid prisma.repo.findMany() invocation:
[web] |
[web] |
[web] | Failed to convert rust String into napi string
[web] | at Vn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7339)
[web] | at Vn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:6663)
[web] | at Vn.request (/app/node_modules/@prisma/client/runtime/library.js:121:6370)
[web] | at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9617)
[web] | at async /app/packages/web/.next/server/chunks/616.js:1:45529
[web] | at async ed (/app/packages/web/.next/server/chunks/616.js:1:37180)
[web] | at async j (/app/packages/web/.next/server/app/[domain]/page.js:1:4646)
[web] | 2025-06-20T18:36:54.842Z error: [web-actions]
[web] | Invalid prisma.repo.findMany() invocation:
[web] |
[web] |
[web] | Failed to convert rust String into napi string
[web] | PrismaClientKnownRequestError:
[web] | Invalid prisma.repo.findMany() invocation:
[web] |
[web] |
[web] | Failed to convert rust String into napi string
[web] | at Vn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7339)
[web] | at Vn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:6663)
[web] | at Vn.request (/app/node_modules/@prisma/client/runtime/library.js:121:6370)
[web] | at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9617)
[web] | at async /app/packages/web/.next/server/chunks/616.js:1:45529
[web] | at async ed (/app/packages/web/.next/server/chunks/616.js:1:37180)
[web] | at async /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:418
[web] | at async rE (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:8148)
[web] | at async r7 (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1144)
[web] | at async doRender (/app/node_modules/next/dist/server/base-server.js:1427:30)
[web] | 2025-06-20T18:37:02.363Z error: [web-actions]
[web] | Invalid prisma.repo.findMany() invocation:
[web] |
[web] |
[web] | Failed to convert rust String into napi string
[web] | PrismaClientKnownRequestError:
[web] | Invalid prisma.repo.findMany() invocation:
[web] |
[web] |
[web] | Failed to convert rust String into napi string
[web] | at Vn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7339)
[web] | at Vn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:6663)
[web] | at Vn.request (/app/node_modules/@prisma/client/runtime/library.js:121:6370)
[web] | at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9617)
[web] | at async /app/packages/web/.next/server/chunks/616.js:1:45529
[web] | at async ed (/app/packages/web/.next/server/chunks/616.js:1:37180)
[web] | at async j (/app/packages/web/.next/server/app/[domain]/page.js:1:4646)

To reproduce

Create a "large" instance, for me, on a 128GB system with 16 cores, allocating 14 cores and 64GB to the container, at about 20,000 repos the instance has this problem.

Sourcebot deployment information

Sourcebot version (e.g. v3.0.1): v4.4.0

Additional information

I will be happy to submit a PR for a fix when/if I get the time to chase these code paths and fix them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions