rcssdy
rcssdy
TTCTheo's Typesafe Cult
Created by rcssdy on 10/1/2023 in #questions
Undici error (Drizzle + Next.js 13.5)
I'm getting an odd error with Undici; after looking things up, I've not had any luck. Here is the error I'm getting:
⨯ Internal error: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
⨯ Internal error: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The only place in which I use Undici is here:
import { migrate } from "drizzle-orm/planetscale-serverless/migrator";
import { connect } from "@planetscale/database";
import { drizzle } from "drizzle-orm/planetscale-serverless";

import { fetch } from "undici";

import "dotenv/config";

const runMigrate = async () => {
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is not defined");
}

const connection = connect({
url: process.env.DATABASE_URL!,
fetch: fetch,
});

const db = drizzle(connection);

console.log("⏳ Running migrations...");

const start = Date.now();

await migrate(db, { migrationsFolder: "src/lib/db/migrations" });

const end = Date.now();

console.log(`✅ Migrations completed in ${end - start}ms`);

process.exit(0);
};

runMigrate().catch((err) => {
console.error("❌ Migration failed");
console.error(err);
process.exit(1);
});
import { migrate } from "drizzle-orm/planetscale-serverless/migrator";
import { connect } from "@planetscale/database";
import { drizzle } from "drizzle-orm/planetscale-serverless";

import { fetch } from "undici";

import "dotenv/config";

const runMigrate = async () => {
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is not defined");
}

const connection = connect({
url: process.env.DATABASE_URL!,
fetch: fetch,
});

const db = drizzle(connection);

console.log("⏳ Running migrations...");

const start = Date.now();

await migrate(db, { migrationsFolder: "src/lib/db/migrations" });

const end = Date.now();

console.log(`✅ Migrations completed in ${end - start}ms`);

process.exit(0);
};

runMigrate().catch((err) => {
console.error("❌ Migration failed");
console.error(err);
process.exit(1);
});
Even after removing this, I get the same error. Does anyone have any idea what this could be associated with? Also, the odd thing is… I’m not running this at all. It happens when I try to insert a new record into the database. For reference, I am using Drizzle inside of my server actions.
4 replies