Niels
Niels
Explore posts from servers
PPrisma
Created by Niels on 4/29/2025 in #help-and-questions
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled
For some reason, when I use the @prisma/adapter-pg and pass my Postgres connectionString, I get the following error? What could cause this? I'm just running locally using next dev?
○ Compiling /instrumentation ...
⨯ cloudflare:sockets
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/pg-cloudflare/dist/index.js
.../node_modules/pg/lib/stream.js
.../node_modules/pg/lib/connection.js
.../node_modules/pg/lib/index.js
.../node_modules/pg/esm/index.mjs
.../node_modules/@prisma/adapter-pg/dist/index.mjs
./src/instrumentations/prisma/seeding.instrumentation.node.ts

[Error: An error occurred while loading instrumentation hook: Cannot find module '/path/to/project/.next/server/instrumentation'
Require stack:
- /path/to/project/node_modules/next/dist/server/dev/next-dev-server.js
- /path/to/project/node_modules/next/dist/server/next.js
- /path/to/project/node_modules/next/dist/server/lib/start-server.js] {
code: 'MODULE_NOT_FOUND',
requireStack: [Array]
}
○ Compiling /instrumentation ...
⨯ cloudflare:sockets
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/pg-cloudflare/dist/index.js
.../node_modules/pg/lib/stream.js
.../node_modules/pg/lib/connection.js
.../node_modules/pg/lib/index.js
.../node_modules/pg/esm/index.mjs
.../node_modules/@prisma/adapter-pg/dist/index.mjs
./src/instrumentations/prisma/seeding.instrumentation.node.ts

[Error: An error occurred while loading instrumentation hook: Cannot find module '/path/to/project/.next/server/instrumentation'
Require stack:
- /path/to/project/node_modules/next/dist/server/dev/next-dev-server.js
- /path/to/project/node_modules/next/dist/server/next.js
- /path/to/project/node_modules/next/dist/server/lib/start-server.js] {
code: 'MODULE_NOT_FOUND',
requireStack: [Array]
}
I've just done it the way described in https://www.prisma.io/docs/orm/overview/databases/postgresql#using-the-node-postgres-driver
3 replies
BABetter Auth
Created by Niels on 4/1/2025 in #help
Manually create a session
Hi, for testing purposes I want to create a session in my own controller, and set the right cookies. Although, it seems like the sesison token has to be in a certain structure. Has anyone got a better idea on how I can implement this? The cookie names do match, I am using NextJS so I would need a backend approach to create the sessions.
// Create or get the test user
const user = await plainPrisma.user.upsert({
where: { email: STAGING_EMAIL },
update: {},
create: {
email: STAGING_EMAIL,
name: "Staging Test",
},
});

// Create a session
const session = await plainPrisma.session.create({
data: {
token: nanoid(64),
userId: user.id,
userAgent: "Playwright",
ipAddress: "::1",
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now
},
});

const secureCookie = true;

// Set cookie through Next.js API
const cookieStore = await cookies();
cookieStore.set("better-auth.session_token", session.token, {
expires: session.expiresAt,
httpOnly: true,
secure: secureCookie,
sameSite: "lax",
path: "/",
});

cookieStore.set("__Secure-better-auth.session_token", session.token, {
expires: session.expiresAt,
httpOnly: true,
secure: secureCookie,
sameSite: "lax",
path: "/",
});
// Create or get the test user
const user = await plainPrisma.user.upsert({
where: { email: STAGING_EMAIL },
update: {},
create: {
email: STAGING_EMAIL,
name: "Staging Test",
},
});

// Create a session
const session = await plainPrisma.session.create({
data: {
token: nanoid(64),
userId: user.id,
userAgent: "Playwright",
ipAddress: "::1",
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now
},
});

const secureCookie = true;

// Set cookie through Next.js API
const cookieStore = await cookies();
cookieStore.set("better-auth.session_token", session.token, {
expires: session.expiresAt,
httpOnly: true,
secure: secureCookie,
sameSite: "lax",
path: "/",
});

cookieStore.set("__Secure-better-auth.session_token", session.token, {
expires: session.expiresAt,
httpOnly: true,
secure: secureCookie,
sameSite: "lax",
path: "/",
});
7 replies
PPrisma
Created by Niels on 10/31/2024 in #help-and-questions
Way to run migrations & seeding using the PrismaClient
Hi, is it possible to run the migrations and seedings for Prisma at runtime using the PrismaClient instance? Would prevent me from having to bundle all source files into my docker containers as well, since its all compiled down.
7 replies
PPrisma
Created by Niels on 8/22/2024 in #help-and-questions
Prisma keeps generating same migrations
No description
4 replies