Adaptor with custom TypeORM model doing custom CRUD will run into `EntityMetadataNotFoundError` "No metadata for "User" was found", in a serverless setting
See original GitHub issueBackground
This is working very well locally as well as on Heroku too. It just fails to work in a serverless setting such as Vercel. So quite a curious thing.
What I’m doing
I’m doing some customsiation on top of Next Auth where I take Next Auth’s typeORM adaptor out and uses it in another API to do custom CRUD for my user table.
Basically I have this:
export const adapterSingleton = ():any=>{
return Adapters.TypeORM.Adapter(
process.env.NEXT_ACCOUNT_DATABASE_URL,
{
models: Models,
}
)
}
and I will take it out like this const adapter = await adapterSingleton().getAdapter()
and uses it.
But after deloying into a serverless setting (Vercel) I keep getting EntityMetadataNotFoundError
when I’m trying to do custom CRUD. Somehow it can’t derive the entity for User
?
Questions
- Does anyone know what’s going on? Can it be related to this: https://github.com/typeorm/typeorm/issues/1327 ? Will using an ormconfig.yml and doing something like
entities: [__dirname + '/**/*.entity.{js,ts}'
fixes it? How do I use ormconfig.yml in this case?
-
What can I do in order to be able to do custom CRUD using NextAuth’s Adaptor without running into this error in a serverless setting? (Was working so well locally!)
-
Or should I give up trying to get this work in TypeORM cuz TypeORM is not really designed to work in this scenaior if it is serverless?
Any tips on this will be appreicated! Thanks!
What are you trying to do custom CRUD
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
@archywillhe Thanks for the insights and work around you have posted!
I have not been able to replicate this issue but I’ve tagged it with a bug so we are tracking it.
Feedback, even anecdotal, from anyone else seeing or not seeing this bug is appreciated.
@iaincollins just bumping this here - am getting ready to release our conversion to
next-auth
from passport-js and am thrilled with how it’s working and how easy it has been to integrate with what we have. Am running in to this exact bug mentioned above here…QueryFailedError: relation "user__users" does not exist
gonna look in to it and will report back. we are on vercel serverless as well.