sebramirez
sebramirez

Reputation: 29

Trying to connect to Turso from Prisma generates a TypeError (duplex option is required when sending a body)

I'm trying to use prisma with turso, I know this isn't a fully supported use-case, but I did see it's a preview feature and I plan on making a next.js app that's hosted on vercel for free hosting with a turso database so I can get a free database too and not have any initial spending or needing to deal with mongoDB and a small data limit, that being said, I am running into a problem where when I follow this guide: https://www.prisma.io/docs/orm/overview/databases/turso I get an error like this one:

TypeError: RequestInit: duplex option is required when sending a body. at node: internal/deps/undici/undici:13193:13 {clientVersion: '5.18.0'}, I figured out this is an error based on how you make your fetch requests so I figure it's an error with how the adapter gets data from turso's servers, here's my db.ts code where I start my prisma instance

import { PrismaClient } from "@prisma/client";
import { PrismaLibSQL } from "@prisma/adapter-libsql";
import { createClient } from '@libsql/client';

const libsql = createClient({
    url: `${process.env.TURSO_DATABASE_URL}`,
    authToken: `${process.env.TURSO_AUTH_TOKEN}`,
})

declare global {
    var prisma: PrismaClient | undefined;
};

const adapter = new PrismaLibSQL(libsql);

// export const db = globalThis.prisma || new PrismaClient({adapter});
export const db = globalThis.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") globalThis.prisma = db;

the commented line is what's expected to happen, the second line is what I needed to do for it to work at all while I'm developping, once I remove the adapter from PrismaClient everything's fine and I get no errors so I do think it's something about how the adapter gets turso's information, if anyone has any advice on how I can get this up and running I'd appreciate it, even an aternative guide or something to point me in the right direction because I'm honestly about to just ditch prisma completely and just have sanitized sql queries.

I tried to get my turso database to work with prisma in a way described on prisma's website and I was expecting to just be able to use prisma to do operations on the database as expected.

Edit: I completely uninstalled prisma, and I'm still having this issue with just libsql/client, so I'm not really sure what to do now, as far as I can tell the only viable solution seems to be downgrading next.js which I don't really wanna do, will update if I end up finding a solution though.

Upvotes: 0

Views: 113

Answers (0)

Related Questions