-
Notifications
You must be signed in to change notification settings - Fork 21
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
[WIP] Use cls-hooked instead of continuation-local-storage #2
[WIP] Use cls-hooked instead of continuation-local-storage #2
Conversation
as suggested by @raymondfeng in strongloop/loopback-context PR strongloop#1 comment #235931961
@josieusa Thank you for the patch. One possibility is to make it conditional based on the minimum Node.js version. |
@raymondfeng I was just going to commit the conditional logic you are talking about. I only need to do more testing. |
Can one of the admins verify this patch? |
@josieusa thank you for the patch, it's great to see community contribution so quickly after creating this new module! 👏 I am afraid the conditional require will not work well, because
I guess we could go with an optional dependency? Alternatively, we can have @raymondfeng thoughts? |
@bajtos Regarding the lost context issues with I made an example Loopback v3 app which tries to reproduce the bug (i.e. it uses
So, manual tests suggest that this branch of mine doesn't solve the lost context issue, at least for So, before continuing to contribuite, I'm going to try to figure out why the two apps behave differently in my manual tests, i.e. what are the differences between the two apps (if any, because it could be just |
@bajtos @josieusa As you have brainstormed, there are a few options to make cls-hooked conditional.
|
Good news. I figured out the differences between my two test apps, and all my manual tests are passing now. |
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
Please don't open a new pull request and keep your changes in this pull request (your feature branch). That way the history of our discussion is preserved in a single place. |
As suggested by @raymondfeng in strongloop/loopback-context PR strongloop#2 comment #236644728
Leaving a note here, @marlonkjoseph had a snippet that reproduces continuation-local-storage loosing active context |
Thanks, I will use it to write a test that fails with the official branch but not this branch of mine. |
Hello, |
I couldn't manage to detect when
I believe it's an improvement, I only need to test it. |
As suggested by @raymondfeng in strongloop/loopback-context PR strongloop#2 comment #236644728
I continued experimenting, and I just had some success in detecting if some of the "cls-unfriendly" modules are imported, and also if the necessary CLS shims for those modules (for example |
Great news! Just pushed! The approach I described is implemented for the most part, and is clear from looking at the tests now. I summarize again:
Let me know if someone wishes to give a look at it. For example, launch the tests by running |
@josieusa Hey, I am glad you are making progress in your work here. We (the LoopBack team) don't have applications where to test your new version, and to be honest, CLS-based current-context is not a priority for us. Take as much time as you need to get this pull request into state where you consider it production-ready. We'll leave this work in the hands of you and any other community members interested in CLS-based current-context. Just let us know when you get to the state where you will consider the implementation production-ready. |
I closed this in favor of PR #11 |
Hello,
I just wanted to let you know that, in this branch of mine,
npm run test
passes.So, this PR is meant as a starting point for you.
Of course there are still two unsolved problems at least:
PS
npm run test
passes using loopback v2, too.Thank you for your attention.
Contents of this PR:
Use cls-hooked instead of continuation-local-storage,
as suggested by @raymondfeng
in strongloop/loopback-context PR #1 comment #235931961
#1 (comment)