P
Prisma6mo ago
Niels

Missing configured driver adapter

Hi When using the driver adapters & query compiler, in combination with the readReplicas extension, I get this vague error. Is this a bug, unsupported, or am I overlooking somethiing?
[next] ⨯ Error [PrismaClientInitializationError]: Missing configured driver adapter. Engine type `client` requires an active driver adapter. Please check your PrismaClient initialization code.
[next] at Array.map (<anonymous>)
[next] at createReplicaPrismaClient (src/libs/prisma/factory.ts:125:15)
[next] at <unknown> (src/libs/prisma/plain/base-client.ts:13:28)
[next] 123 | }
[next] 124 |
[next] > 125 | return client.$extends(readReplicas({ url: connectionString }));
[next] | ^
[next] 126 | }
[next] 127 |
[next] 128 | /** {
[next] ⨯ Error [PrismaClientInitializationError]: Missing configured driver adapter. Engine type `client` requires an active driver adapter. Please check your PrismaClient initialization code.
[next] at Array.map (<anonymous>)
[next] at createReplicaPrismaClient (src/libs/prisma/factory.ts:125:15)
[next] at <unknown> (src/libs/prisma/plain/base-client.ts:13:28)
[next] 123 | }
[next] 124 |
[next] > 125 | return client.$extends(readReplicas({ url: connectionString }));
[next] | ^
[next] 126 | }
[next] 127 |
[next] 128 | /** {
export function createReplicaPrismaClient({
connectionString,
enableLogging = process.env.PRISMA_LOG === "true",
readReplicaUrl = process.env.DATABASE_URL_READ_REPLICA,
}: CreatePrismaClientOptions) {
// Create postgres adapter
const adapter = new PrismaPg({
connectionString,
});

const client = new PrismaClient({
adapter,
log: enableLogging ? ["query", "info", "warn", "error"] : ["error"],
});

// Apply read replica extension if configured
if (readReplicaUrl) {
return client.$extends(readReplicas({ url: readReplicaUrl }));
}

return client.$extends(readReplicas({ url: connectionString }));
}
export function createReplicaPrismaClient({
connectionString,
enableLogging = process.env.PRISMA_LOG === "true",
readReplicaUrl = process.env.DATABASE_URL_READ_REPLICA,
}: CreatePrismaClientOptions) {
// Create postgres adapter
const adapter = new PrismaPg({
connectionString,
});

const client = new PrismaClient({
adapter,
log: enableLogging ? ["query", "info", "warn", "error"] : ["error"],
});

// Apply read replica extension if configured
if (readReplicaUrl) {
return client.$extends(readReplicas({ url: readReplicaUrl }));
}

return client.$extends(readReplicas({ url: connectionString }));
}
8 Replies
Prisma AI Help
Prisma AI Help6mo ago
You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.
Nurul
Nurul6mo ago
Hi @Niels! Does the error go away if you remove readReplicas extension? Which prisma version are you using?
Niels
NielsOP6mo ago
Yes indeed, using latest for both the extension & prisma.
Nurul
Nurul6mo ago
Thanks for confirming. And this happens when you try to generate PrismaClient with npx prisma generate?
Niels
NielsOP5mo ago
No, it happens during runtime. The client is generated within the function, and this function is only called during requests. Have there been other reports of the same issue?
Nurul
Nurul5mo ago
No, I am not aware of any other reports. Would it be possible to provide a minimal reproducible example so that I can raise it internally?
Niels
NielsOP5mo ago
Sure 👍
Niels
NielsOP3mo ago
Fixed it myself, the extension assumed that the client could be constructed with a datasourceUrl, but from now on, it can either be with an adapter OR datasourceUrl. https://github.com/prisma/extension-read-replicas/blob/7874a2122f9b0b529f03a16e020316bf9bb733c3/src/ReplicaManager.ts#L33
No description

Did you find this page helpful?