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

typeorm-transactional-cls-hooked initialization #30

Closed
demostenes1509 opened this issue Sep 28, 2019 · 2 comments
Closed

typeorm-transactional-cls-hooked initialization #30

demostenes1509 opened this issue Sep 28, 2019 · 2 comments

Comments

@demostenes1509
Copy link

Hi, @odavid !

This is not an issue, its just a warning to devs community.

My app is spread between several modules, and in order to 'reuse' code, I did something like this:

import {
  initializeTransactionalContext,
  patchTypeORMRepositoryWithBaseRepository,
} from 'typeorm-transactional-cls-hooked';

export const initializeTransactions = () => {
  initializeTransactionalContext(); 
  patchTypeORMRepositoryWithBaseRepository(); 
};

And ...

import { initializeTransactions } from 'mylib';

async function bootstrap() {
  initializeTransactions();
...
...

Code above makes transactions dont work ! Transaction initialization must be in the SAME module that it will used. I spend 3 hours researching why library was not working ... haha !

Best, and my warm congrats for this esplendid library !

@kerren
Copy link

kerren commented Oct 12, 2019

Hi @demostenes1509 can you please elaborate on what you mean by "module" in this case?

Are you saying that it must be done in the index.ts of your application (assuming that's your entry point) or does that mean that you need to always have this import in the file when you're using the transaction decorator?

@odavid
Copy link
Owner

odavid commented Oct 24, 2019

Hi @demostenes1509,
First of all thanks for the "warm congrats" 😄

I think that the issue you mention here can be related to using dependencies and not peerDependencies in your modules. I did not have the chance to test it myself, but I assume this is the root cause.

Best,
Ohad

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

3 participants