Skip to content
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

Reuse connection only after the entity metadatas are registered #33

Open
GaaraZhu opened this issue Jul 21, 2024 · 0 comments
Open

Reuse connection only after the entity metadatas are registered #33

GaaraZhu opened this issue Jul 21, 2024 · 0 comments

Comments

@GaaraZhu
Copy link

GaaraZhu commented Jul 21, 2024

This line of code will return a connection right after it's created as step one of createConnection in line 16, but step two buildMetadatas may not be finished yet. In that case the connection will throw an error when trying to get entity repository.
Screenshot 2024-07-22 at 10 49 13 AM

To reproduce it, trigger two async init operations on a new new EventStore(config.dbConnections.eventStore as never)

const eventStoreRepo = new EventStoreRepoTypeOrm(config.dbConnections.eventStore as never)
eventStoreRepo.init()
eventStoreRepo.init()

Error:
Screenshot 2024-07-22 at 9 46 56 AM

Solutions:

  • reuse the connection only after the entity metadatas are registered
Screenshot 2024-07-22 at 10 43 05 AM
  • init the repositories outside only once at a time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant