keystone
keystone copied to clipboard
An error occurred handling a request for the Admin UI: Error: Prisma error
Bug report
Hi, I have a problem with last update (5th october), my backend doesn't start
Describe the bug
When I tried to access to my Keystone Dashboard (http://localhost:3008 for me) I have this error :
An error occurred handling a request for the Admin UI: Error: Prisma error:
at Object.prismaError (/Project/backend/node_modules/@keystone-next/keystone/dist/graphql-errors-80e88b8e.cjs.dev.js:26:10)
at runWithPrisma (/Project/backend/node_modules/@keystone-next/keystone/dist/types-for-lists-99088921.cjs.dev.js:29:25)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at Object.count (/Project/backend/node_modules/@keystone-next/keystone/dist/types-for-lists-99088921.cjs.dev.js:891:17)
at async Promise.all (index 0)
at Object.runGraphQL [as run] (/Project/backend/node_modules/@keystone-next/keystone/dist/initConfig-b1c5e342.cjs.dev.js:2829:20)
at Object.count (/Project/backend/node_modules/@keystone-next/keystone/dist/initConfig-b1c5e342.cjs.dev.js:2329:24)
at pageMiddleware (/Project/backend/node_modules/@keystone-next/auth/dist/auth.cjs.dev.js:740:21)
at Object.pageMiddleware (/Project/backend/node_modules/@keystone-next/auth/dist/auth.cjs.dev.js:952:43)
at /Project/backend/node_modules/@keystone-next/keystone/dist/createAdminUIMiddleware-12500ace.cjs.dev.js:162:29 {
locations: [ { line: 1, column: 35 } ],
path: [ 'count' ],
extensions: { prisma: { clientVersion: '2.22.1' }, code: 'KS_PRISMA_ERROR' }
To Reproduce
- In package.json
"dependencies": {
"@keystone-next/auth": "33.0.0",
"@keystone-next/fields": "15.0.0",
"@keystone-next/fields-document": "9.0.0",
"@keystone-next/types": "25.0.0",
"@keystone-next/utils": "2.0.0",
"@keystone-next/admin-ui": "^14.1.3",
"@keystone-next/keystone": "26.1.1",
"@keystone-next/document-renderer": "4.0.1",
"@keystonejs/server-side-graphql-client": "^2.1.2",
"@types/nodemailer": "^6.4.4",
"dotenv": "^10.0.0",
"next": "^11.1.2",
"nodemailer": "^6.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"stripe": "^8.161.0"
},
"devDependencies": {
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"babel-eslint": "^10.1.0",
"eslint": "^7.30.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-wesbos": "^2.0.0-beta.4",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"prettier": "^2.3.2",
"typescript": "^4.4.4"
}
- Keystone.ts
import { createAuth } from '@keystone-next/auth';
import { statelessSessions } from '@keystone-next/keystone/session';
import { config } from '@keystone-next/keystone';
import 'dotenv/config';
// -- Schemas
import { KeystoneContext } from '@keystone-next/keystone/types';
import { User } from './schemas/User';
import { Product } from './schemas/Product';
import { ProductImage } from './schemas/ProductImage';
import { ProductCategory } from './schemas/ProductCategory';
import { CartItem } from './schemas/CartItem';
import { OrderItem } from './schemas/OrderItem';
import { Order } from './schemas/Order';
import { Role } from './schemas/Role';
import { insertSeedData } from './seed-data';
import { sendPasswordResetEmail } from './lib/mail';
import { extendGraphqlSchema } from './resolvers/index';
import { permissionsList } from './schemas/PermissionField';
import { Session } from './types';
const databaseUrl =
// process.env.DATABASE_URL || 'mongodb://localhost/keystone-dev';
process.env.DATABASE_URL || 'postgres://postgres@localhost/test';
const { withAuth } = createAuth({
listKey: 'User',
identityField: 'email',
secretField: 'password',
initFirstItem: {
fields: ['name', 'email', 'password'],
// -- Initial role
itemData: {
role: {
create: {
name: 'initial role',
...permissionsList.reduce((result, permission) => {
result[permission] = true;
return result;
}, {}),
},
},
},
},
passwordResetLink: {
async sendToken(args) {
const { token, identity } = args;
console.log('Token/Identity', token, identity);
await sendPasswordResetEmail(token, identity);
},
},
sessionData: `name email role { ${permissionsList.join(' ')} }`,
});
const sessionConfig = {
maxAge: 60 * 60 * 24 * 360,
secret: process.env.COOKIE_SECRET || 'cookie-dev',
};
export default withAuth(
config({
server: {
port: Number(process.env.PORT) || 3008,
cors: {
origin: [process.env.FRONTEND_URL],
credentials: true,
},
},
db: {
provider: 'postgresql',
url: databaseUrl,
async onConnect(context) {
console.log('🎠 Connected to the database!');
if (process.argv.includes('--seed-data')) {
await insertSeedData(context);
}
},
},
images: { upload: 'local' },
lists: {
// Schema
User,
Product,
ProductImage,
ProductCategory,
CartItem,
OrderItem,
Order,
Role,
},
extendGraphqlSchema,
ui: {
isAccessAllowed: (context: KeystoneContext): boolean => {
const session = context.session as Session;
return !!session?.data;
},
},
session: statelessSessions(sessionConfig),
})
);
Expected behaviour
I wish I didn't have this mistake anymore. Understand where it comes from
Screenshots
- Schema.prisma
System information
- MacOS Big Sur 11.6 - M1
- With
yarn dev
and withdocker-compose
Related Keystone Community Slack thread - https://keystonejs.slack.com/archives/C01STDMEW3S/p1634977314082000
I'm having the same issue, is there any work arounds?
Any news on this? It fails with the default setup when creating a Keystone app
~I have a slight suspicion that it's somehow related to apple silicone, Is that possible? It works on 3 devices I checked, but not on my apple silicone.~ nvm. Just use node 16
@datner, working fine on Apple Silicon on my end.
@stevenbrown125, @bjufre, @datner could you please share your repo where you're getting this issue? I'll take a look.
@bladey nah I'm a donkey, I just had node 17 on this machine and node 16 on all the others. Downgraded and everything works like magic. I feel silly now lol
ref: https://github.com/prisma/prisma/issues/10018#issuecomment-954755144
No worries, really appreciate the update, thank you.
Marked as stale, if anyone can reproduce this problem, please comment or open a new issue