prisma-session-store: "Record to delete does not exist" error
Hi there, we are considering using this library to help us with our Express + Prisma DB-backed sessions at Wasp. In trying it out locally and on Heroku, I found I get similar failures related to deletion that I am unable to diagnose.
For example, locally, when setting:
resave: false,
saveUninitialized: false,
I get the following error:
Server: Error:
Server (stderr): Invalid `this.prisma[this.sessionModelName].delete()` invocation in
Server (stderr): /Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/@quixo3/prisma-session-store/dist/lib/prisma-session-store.js:266:91
Server (stderr):
Server (stderr): 263 case 3:
Server (stderr): 264 _a.sent();
Server (stderr): 265 return [3 /*break*/, 6];
Server (stderr): → 266 case 4: return [4 /*yield*/, this.prisma[this.sessionModelName].delete(
Server (stderr): An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
Server (stderr): at cb (/Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/.prisma/client/runtime/index.js:38703:17)
Server (stderr): at async PrismaClient._request (/Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/.prisma/client/runtime/index.js:40853:18)
Server (stderr): set(): Error:
Server (stderr): Invalid `this.prisma[this.sessionModelName].create()` invocation in
Server (stderr): /Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/@quixo3/prisma-session-store/dist/lib/prisma-session-store.js:493:85
Server (stderr):
Server (stderr): 490 case 4:
Server (stderr): 491 _a.sent();
Server (stderr): 492 return [3 /*break*/, 7];
Server (stderr): → 493 case 5: return [4 /*yield*/, this.prisma[this.sessionModelName].create(
Server (stderr): Unique constraint failed on the fields: (`id`)
Server (stderr): POST /auth/login 200 142.790 ms - 1002
Server: Error:
Server (stderr): Invalid `this.prisma[this.sessionModelName].create()` invocation in
Server (stderr): /Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/@quixo3/prisma-session-store/dist/lib/prisma-session-store.js:493:85
Server (stderr):
Server (stderr): 490 case 4:
Server (stderr): 491 _a.sent();
Server (stderr): 492 return [3 /*break*/, 7];
Server (stderr): → 493 case 5: return [4 /*yield*/, this.prisma[this.sessionModelName].create(
Server (stderr): Unique constraint failed on the fields: (`id`)
Server (stderr): at cb (/Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/.prisma/client/runtime/index.js:38703:17)
Server (stderr): at async PrismaClient._request (/Users/shayne/dev/wasp/waspc/examples/todoApp/.wasp/out/server/node_modules/.prisma/client/runtime/index.js:40853:18)
Server (stderr):
I did see the session was actually persisted, however.
And on Heroku, with the following settings (interestingly these did work locally, but other permutations caused issues locally):
resave: false,
saveUninitialized: true,
I got the following error:
2022-06-14T17:37:12.221722+00:00 app[web.1]: Error: An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
2022-06-14T17:37:12.221732+00:00 app[web.1]: at cb (/app/server/node_modules/.prisma/client/runtime/index.js:38703:17)
2022-06-14T17:37:12.221733+00:00 app[web.1]: at async PrismaClient._request (/app/server/node_modules/.prisma/client/runtime/index.js:40853:18)
2022-06-14T17:37:12.229882+00:00 app[web.1]: set(): Error: Unique constraint failed on the fields: (`id`)
2022-06-14T17:37:12.230167+00:00 app[web.1]: [0mPOST /auth/login [32m200 [0m284.895 ms - 148[0m
2022-06-14T17:37:12.230431+00:00 app[web.1]: Error: Unique constraint failed on the fields: (`id`)
2022-06-14T17:37:12.230432+00:00 app[web.1]: at cb (/app/server/node_modules/.prisma/client/runtime/index.js:38703:17)
2022-06-14T17:37:12.230433+00:00 app[web.1]: at async PrismaClient._request (/app/server/node_modules/.prisma/client/runtime/index.js:40853:18)
We are using Prisma v3.9.1 and a callback style similar to this example for our login sessions: https://github.com/expressjs/session#user-login where we save inside a regenerate.
Here is the full session store config in which the above lives:
const sessionConfig = {
name: config.session.name,
secret: config.session.secret,
resave: false, // ☝️
saveUninitialized: false, // ☝️
cookie: {
httpOnly: true,
maxAge: config.session.cookie.maxAge,
},
store: new PrismaSessionStore(prisma, {
checkPeriod: 2 * 60 * 1000, //ms
dbRecordIdIsSessionId: true,
dbRecordIdFunction: undefined
})
}
Are the errors I am getting due to this style of saving the session, or perhaps from the config settings? Anything else I can do to help debug this, as I’m not entirely sure what the library is attempting to do there with the deletions? Thanks!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26 (9 by maintainers)
Same error. #93 does not resolve this.
Hello, I’m having similar issue using passport in #81 my issue.
This issue should now be fixed in master, based on PR #102 - thanks to @geefuoco.
(Please post if it resurfaces.)
I created a pr with this issue fixed https://github.com/kleydon/prisma-session-store/pull/102#issue-1345392142
Here is my temporary hack until this issue is resolved:
Ok - lines deleted in PR #98.
Hi @shayneczyzewski - thanks for the bug report.
I’m using the same parameter values - resave: false, saveUninitialized: false - in one project; will keep a look out to see if I encounter this error.
Note: A recent fix from PR #93 may improve matters; not yet sure.