Open Elsoberanold opened 1 year ago
@Elsoberanold - Thanks for reporting this. Haven't used Edge or Fastify, so not immediately sure what's going on here... If the problem persists perhaps you could post a minimal reproduction? I'm a bit short on time over the near term, but hopefully others can jump in, given an example to test from.
@Elsoberanold - Thanks for reporting this. Haven't used Edge or Fastify, so not immediately sure what's going on here... If the problem persists perhaps you could post a minimal reproduction? I'm a bit short on time over the near term, but hopefully others can jump in, given an example to test from.
This weekend I will try to post a small example to reproduce this error!
@kleydon I have made an example app that reproduces this error.
https://github.com/Elsoberanold/fastify-passport-session-example
Thanks @Elsoberanold.
Any prisma-session-store
users out there using fastify + passport session, who might have a quick insight on this?
mongodb + prisma + passport + nodejs + express
' 540 case 4:\n' +
' 541 _a.sent();\n' +
' 542 return [3 /*break*/, 7];\n' +
'→ 543 case 5: return [4 /*yield*/, this.prisma[this.sessionModelName].create(\n' +
`Inconsistent column data: Malformed ObjectID: invalid character 'k' was found at index 0 in the provided hex string: "kUvJl1mpDqEYFkN9X67aCp5mwT-X3TSn" for the field 'id'.`,
I encountered the same error, but I managed to resolve it by modifying the session model.
model Session {
id String @id @map("_id")
sid String @unique
data String
expiresAt DateTime
}
The issue was likely primarily caused by the definition of the id field. In my case, I used id String @id @default(auto()) @map("_id") @db.ObjectId
which resulted in the error. After changing it to the definition mentioned above, the error disappeared, and the session could be successfully stored in the database.
@Rabithua - Thanks for posting this fix.
This code was tested on Firefox and was able to run as expected, although that was not the case with Microsoft Edge... Server Log shows the following error:
Prisma schema:
For this project I've used fastify with @fastify/session plugin
I have checked db with prisma studio and session rows are being created on session table, although passport user is set to null on req.user.
Packages versions: "prisma": "^4.5.0", "@prisma/client": "^4.5.0", "fastify": "^4.9.2", "@fastify/session": "^10.0.2", "@fastify/cookie": "^8.3.0", "@fastify/passport": "^2.2.0", "@quixo3/prisma-session-store": "^3.1.10"