Type error fetch failed
getting this very weird issue with newly created proejct, unable to query anything.
{
e: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async postJSON (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:128:22)
at async Connection.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:86:23)
at async PlanetScalePreparedQuery.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/planetscale-serverless/index.mjs:31:26)
at async eval (webpack-internal:///(api)/./src/server/api/routers/example.ts:19:23)
at async resolveMiddleware (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/index.mjs:420:30)
at async callRecursive (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/index.mjs:456:32)
at async callRecursive (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/index.mjs:456:32)
at async resolve (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/index.mjs:486:24)
at async inputToProcedureCall (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:46:22)
at async Promise.all (index 0)
at async resolveHTTPResponse (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:182:37)
at async file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/nodeHTTPRequestHandler-dbf26ba2.mjs:67:9
at async file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/dist/adapters/next.mjs:44:9 {
cause: [Error: 0093F4DB01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:
] {
library: 'SSL routines',
reason: 'wrong version number',
code: 'ERR_SSL_WRONG_VERSION_NUMBER'
}
}
}
[next-auth][error][adapter_error_getSessionAndUser]
https://next-auth.js.org/errors#adapter_error_getsessionanduser fetch failed {
message: 'fetch failed',
stack: 'TypeError: fetch failed\n' +
' at Object.fetch (node:internal/deps/undici/undici:11576:11)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async postJSON (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:128:22)\n' +
' at async Connection.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:86:23)\n' +
' at async PlanetScalePreparedQuery.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/planetscale-serverless/index.mjs:31:26)\n' +
' at async getSessionAndUser (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@auth/drizzle-adapter/lib/mysql.js:90:37)',
name: 'TypeError'
}
[next-auth][error][SESSION_ERROR]
https://next-auth.js.org/errors#session_error fetch failed TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async postJSON (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:128:22)
at async Connection.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:86:23)
at async PlanetScalePreparedQuery.execute (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/planetscale-serverless/index.mjs:31:26)
at async getSessionAndUser (file:///Users/a3tech/Developer/personal_projects/remarkable/node_modules/.pnpm/@[email protected]/node_modules/@auth/drizzle-adapter/lib/mysql.js:90:37) {
name: 'GetSessionAndUserError',
code: undefined
}
Can you share a redacted version of your configuration? This error is fundamentally an SSL issue. So maybe trying to use http when we require https, or the TLS version is too low, which would be quite a bit odd. We require TLS 1.2+.
how do I update TLS? this is my db/index.ts file
import { connect } from "@planetscale/database";
import { drizzle } from "drizzle-orm/planetscale-serverless";
// create the connection
export const connection = connect({
url: process.env.DATABASE_URL!,
});
export const db = drizzle(connection);
It's not typically something you do directly and comes from the underlying networking libraries of the runtime.
Where are you running this and can you share a redacted version of that DATABASE_URL?
running locally, using drizzle:
- Using the optimized connection from planetscale
DATABASE_URL=mysql://user:[email protected]:3306/toldyouso?ssl={"rejectUnauthorized": true}
Aha, so that's what I was looking for. Using port 3306 doesn't work. We should auto fix this in database-js, but this connection string is not correct here.
You'd want something like this:
DATABASE_URL=https://user:[email protected]
I'll open up and issue about ignoring the 3306 part since that will never work.
right thanks a lot!, I also tried using USERNAME, HOST and PASSWORD instead, like this:
import { env } from "~/env.mjs";
import * as schema from "./schema";
import { connect } from "@planetscale/database";
import { drizzle } from "drizzle-orm/planetscale-serverless";
// create the connection
const connection = connect({
host: env.DATABASE_HOST,
username: env.DATABASE_USERNAME,
password: env.DATABASE_PASSWORD,
});
export const db = drizzle(connection, { schema });
and this seems to work nicely too
this issue had me blocked for hours lol
When you had to split up, was :3306 inside DATABASE_HOST too? If so, same issue.
actually not, I used the credentials generated from pscale cli and it only included the name aws.psdb.cloud.com
running into that issue using prisma/kysely and the planetscale cli proxy that allows me to connect to mysql://127.0.0.1/foo
any way around it?