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.

Can not spawn Query Engine when using Electron

See original GitHub issue

Problem

The ASAR file format is an archive used to package the source code and dependencies of an application in Electron. However in order to spawn the Query Engine binary, it has to be outside the ASAR archive, since ASAR archives are read-only and cannot spawn a separate process.

As a solution electron-builder provides a way to unpack or “move” these binaries out of the ASAR archive and into a different location.

However, this leads to a new problem. As the location of the Query Engine binary has changed to a different location, PrismaClient can no longer automatically detect the binary. In such cases, the path for the Query Engine binary needs to be manually passed to the PrismaClient during initialization in this way:

let prisma = new PrismaClient({
   __internal: {
    engine: {
      binaryPath: "/path/to/binary"
    }
  }
})

However, this API is currently not public and undocumented, making it difficult for usage by people outside of Prisma.

Suggested solution

Either of the following seem like acceptable solutions:

  1. This API needs to be made public and documented. OR
  2. Some provision needs to be added so that the PrismaClient can automatically locate the path to the unpacked Query Engine binary.

Existing Workaround: Use the private API for the moment.

Related Issues/Discussions:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TasinIshmamcommented, Dec 7, 2021

Keeping the Prisma libraries binaries out of the ASAR archive using the extraResources configuration option that electron-builder provides seems to work fine. One possible drawback to this is the extra bundle size of the final applicaiton.

Notably, this works for both the new Node-API and the older rust binary. A while ago, I created a small example repo demonstrating how to do the above, I think it might be relevant to anyone facing this issue.

@madebysid @janpio sorry for the delay following up. Please feel free to take a look!

1reaction
janpiocommented, Oct 8, 2021

Ok, good to know the env vars would work. That is much more reasonable than using the internal API (or even making that public).

Yes the problem also applies here, as the Node-API also needs to be spawn'd.

There is no spawning happening for Node-API, only require: https://github.com/prisma/prisma/blob/main/packages/engine-core/src/library/LibraryEngine.ts (vs. https://github.com/prisma/prisma/blob/main/packages/engine-core/src/binary/BinaryEngine.ts) So would be good if we could verify if the Node-API library might even just work fine out of the box.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma Client not finding query-engine after electron ...
prisma" seems like something that is being used by js - I'm surprised it's not imported form the place it needs it; exe...
Read more >
Performance | Electron
A set of guidelines for building performant Electron apps.
Read more >
Roblox spawn script - Divadonna.it
All scripts and cheats on Roblox are run using injectors, you can use your private injector or a free injector from our website....
Read more >
VS Code Sandboxing
The sandbox reduces the harm that malicious code can cause by limiting ... If you are not familiar with VS Code or Electron...
Read more >
How to fix this Error: spawn EACCES - Edward Beazer Blog
How to fix this Error: spawn EACCES ... If that doesn't work try using 777 instead like this ... Hope my tips and...
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