-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatible instance typing while assigning to express-session's store #105
Comments
Hi @rahadi23 - Sorry for the late reply, here. Is |
Hi @kleydon - thank you for the reply. Sorry for the lack of context. Again, this only happen when I upgrade to |
Hmmm... Not sure what is going on. Here's the diff between 3.1.10 and 3.1.9 on GitHub, in case that helps get to the bottom of this. In prisma-session-store (v3.1.9 and v3.1.10), the class definition begins with:
...where Is it possible that in your testing, the version of Alternatively: Perhaps although there is an error, the error message is misleading - and the issue is really something else? Another thought: In v3.1.10, two new properties were added to PrismaSessionStore: store: new PrismaSessionStore(...) You could try: let altStore = new PrismaSessionStore()
//Remove the recently added properties for testing
delete altStore.isSetting
delete altStore.isTouching
...
store: altStore This wouldn't work as a final solution - but perhaps it could help with narrowing down whether or not the problem has to do the addition of these two new properties or not? Also - if you could post a buildable minimal reproduction of what you are seeing, so others could build it and experience the issue directly, this might make it easier for people to debug this in parallel... My time over the near term is a bit limited, but - hopefully this will get solved! I suspect you aren't the only one using this lib with Prisma with NestJS - seems like a really useful/powerful web stack to me. |
I'm getting a similar error, this is my setup:
and TypeScript is throwing this error:
|
@owensj-basis - thanks for the report. Any chance you might be willing to post a minimal reproduction and link to it here, so its easier to problem-solve? |
@owensj-basis I'm facing exactly the same problem. For now, I have fixed it by casting PrismaClient to any. It's not the solution, and I wished I could help, but I'm not particularly good with Typescript. |
Thanks @PhillJK & @owensj-basis! It is people "weighing in" as they can that enables open source projects like these to keep moving forward. Any typescript aficionados out there who rely on this library up for taking a look at this? Thanks, -K |
This was my workaround as well @kleydon I'll see if I can get a minimal reproduction in a separate repo and post if successful |
@owensj-basis Appreciate it! (Hope you don't feel obliged; I'm just trying to "lean on" the whole community that uses this lib, to distribute the workload a bit... :) |
Hi, I have the same problem with NestJS, any news? |
@IonVillarreal, not yet; I've not used NestJS, myself thusfar. |
I'm having the same issue. The only solution I found was to actually stop using the lib and implement the store myself :( |
Hi @andremarcondesteixeira, sorry this lib has been less than helpful for you, at least so far. Curious: If you happen to be using VSCode, and you hover over your own session store implementation, what is the typing that you see for it? (Just wondering if this info might yield clues that suggest a fix for NestJS users...) |
For now, for NestJS, I'm using connect-pg-simple with a similar setup:
|
Hi @olalonde, |
Using Express v5
|
Hi @kleydon , Thank you for taking out time to build this library and making it open source! You are saving tons of time for others! I have followed this code snippet (thanks to @ansemjo) prisma/prisma#10306 (comment) My
My
|
Hi Shridhar,
I'm traveling, but will check this out when I can - probably early next week.
Thanks for posting this!
…-Krispin
On Jun 18, 2023, at 10:54 AM, Shridhar Puntambekar ***@***.***> wrote:
Hi @kleydon , Thank you for taking out time to build this library and making it open source! You are saving tons of time for others!
I am facing the same issue as above, and I have a very simple REST API with express and express-session. The TS issue goes away by using as any
I have followed this code snippet (thanks to @ansemjo) prisma/prisma#10306 (comment)
My session.ts file
import Session from 'express-session';
import { PrismaSessionStore } from ***@***.***/prisma-session-store";
import prisma from '../lib/prisma';
import { SECRETS } from './settings';
// return a session middleware for express
export function getSessionConfig() {
return Session({
name: "sfwtid", // name of the cookie
cookie: {
maxAge: 7 * 24 * 60 * 60 * 1000, // ms, 7 days
sameSite: "strict",
secure: "auto",
},
secret: SECRETS.expressSessionSecret!,
resave: false,
saveUninitialized: false,
unset: "destroy",
store: new PrismaSessionStore(prisma as any, {
checkPeriod: 10 * 60 * 1000, // ms, 10 minutes
dbRecordIdIsSessionId: true,
dbRecordIdFunction: undefined,
}),
});
}
My prisma.ts file
import { PrismaClient } from ***@***.***/client";
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma = globalForPrisma.prisma || new PrismaClient();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
export default prisma;
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
I've just tried the code above (changing
|
I only have the issue with the typing error and "session" when the schema is missing the "Session" type or the client has not been generated properly Anyone having this issue I would check the generated "PrismaClient" from the node_modules folder (or wherever you put it) has the the "session" property from the Session model. all of your models should be a property on the client
Of course check this is in your schema
|
Got an incompatible instance typing while assigning to
express-session
's store with the3.1.10
release as follows:src/main.ts
:package.json
:These configurations work just fine before with the
3.1.9
release. Is there anything needs to be done or are there any migration steps should be followed in order to make it works with the latest release?The text was updated successfully, but these errors were encountered: