Can not spawn Query Engine when using Electron
See original GitHub issueProblem
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:
- This API needs to be made public and documented. OR
- Some provision needs to be added so that the
PrismaClient
can automatically locate the path to the unpackedQuery Engine
binary.
Existing Workaround: Use the private API for the moment.
Related Issues/Discussions:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Keeping the Prisma libraries binaries out of the
ASAR
archive using theextraResources
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!
Ok, good to know the env vars would work. That is much more reasonable than using the internal API (or even making that public).
There is no
spawn
ing happening for Node-API, onlyrequire
: 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.