UnhandledSchemeError when using Drizzle ORM with Next.js authentication application
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Description:
I am encountering an issue while using postgres.js with Drizzle ORM in a Next.js authentication application. Despite not using Cloudflare Workers in my project, I'm encountering an error related to "cloudflare:sockets", indicating an UnhandledSchemeError.
Here's a summary of the relevant code and context:
// db.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
const client = postgres(process.env.DATABASE_URL!);
const db = drizzle(client, { schema });
export default db;
// auth.ts
import NextAuth, { DefaultSession } from "next-auth";
import { authConfig } from "./auth.config";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import db from "@/database/db";
export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
callbacks: {
async session({ token, session }) {
// Session callback logic
},
async jwt({ token }) {
// JWT callback logic
// Issue seems to arise here when interacting with the database
},
},
adapter: DrizzleAdapter(db),
secret: process.env.NEXTAUTH_SECRET,
session: { strategy: "jwt" },
});
// middleware.ts
export {auth as default} from "./auth"
The error message received is:
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.
Import trace for requested module:
cloudflare:sockets
./node_modules/postgres/cf/polyfills.js
./node_modules/postgres/cf/src/index.js
./src/database/db.ts
./src/auth.ts
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Next.js build using src/database/db.ts, src/auth.ts, and middleware.ts, then follow the import trace through node_modules/postgres/cf/polyfills.js and cf/src/index.js. Determine why the application reaches cloudflare:sockets without Cloudflare Workers; done means the build completes and the authentication entry points work without the UnhandledSchemeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, postgres, typescript
- Domain
- authentication, backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100