question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Background

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

  1. 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?

  1. 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!)

  2. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
iaincollinscommented, Oct 27, 2020

@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.

0reactions
followblcommented, Feb 18, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

entitymetadatanotfounderror: no metadata for "users" was found.
2) What can I do in order to be able to do custom CRUD using NextAuth's Adaptor without running into this error in...
Read more >
No metadata for "User" was found using TypeOrm
Inserting a new user into the database... { EntityMetadataNotFound: No metadata for "User" was found. at new EntityMetadataNotFoundError (/Users ...
Read more >
TypeORM - No metadata for "User" was found. - Reddit
Hoping some typeORM experts can help me out, burned wayyy to much time on this. Was wondering if anyone can shed some light...
Read more >
No metadata found for database connection. 0-stable\data ...
This raises another Error Message: Failed to get metadata from database ... TypeORM model doing custom CRUD will run into EntityMetadataNotFoundError "No ......
Read more >
Fix for EntityMetadataNotFound: No metadata was found in ...
In the NestJS application, Created a Custom Entity and corresponding Controller, Service, and started an application, got the below error during startup.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found