odavid / typeorm-transactional-cls-hooked

A Transactional Method Decorator for typeorm that uses cls-hooked to handle and propagate transactions between different repositories and service methods. Inpired by Spring Trasnactional Annotation and Sequelize CLS
MIT License
524 stars 86 forks source link

Hello, could i ask u some question about cls's problem? #50

Closed M1178475702 closed 3 years ago

M1178475702 commented 4 years ago

I'm using sequelize be the orm of my project, and i has implemented a Transactional decorator for sequelize with using cls which has similar function like yours. But in my using cases, i found some problems caused by cls. Something like this: image

Actually, if you use cls, use ns.run (function of cls), when you use [await async func()] in the callback of ns.run, there will be ineffective after retured from await.

i want to get some helps about how you resolve the problem from you if you has encoutered it. Any help will be appriciated!

M1178475702 commented 4 years ago

I have watched your sameple, but there is onle one await function, i couldn't get some help from it. And sorry for my bad english if you think difficult to understand :-(

M1178475702 commented 4 years ago

some cls test cases are here: image

odavid commented 4 years ago

Hi @M1178475702 - looking at the latest example you've sent, I understand the problem you have is that you expect "1" instead of "undefined" in the console.log within func()... I am sorry, but I cannot really think I can help here. I believe this is a question to be asked in jeff-lewis/cls-hooked github project.

Sorry I cannot help more than that.

M1178475702 commented 4 years ago

Hi @M1178475702 - looking at the latest example you've sent, I understand the problem you have is that you expect "1" instead of "undefined" in the console.log within func()... I am sorry, but I cannot really think I can help here. I believe this is a question to be asked in jeff-lewis/cls-hooked github project.

Sorry I cannot help more than that.

Thank you for reply:-) You are right that the problem should be placed in cls..but.. The reason I ased here is I think that you may encoutered similar problem when implement this problem. image

In the final, thank you very much,