-
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
[SEMVER-MAJOR] Replace continuation-local-storage with cls-hooked #11
Conversation
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
Can one of the admins verify this patch? |
f8b0d71
to
b91ed98
Compare
6371337
to
8feccc3
Compare
@@ -2,3 +2,8 @@ | |||
========================= | |||
|
|||
* First release! | |||
|
|||
2016-08-10, Version 2.0.0-alpha.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents in CHANGES.md
is generated by our release tooling, please revert this change.
Ok, I addressed all the line notes from the mantainer; but before removing the [WIP] in the title I'd like to try this in production, despite having some successful tests already in place. I'll let you know soon. |
Sounds good, thank you! |
How soon this come? Maybe you can prepare worked example or change readme.md? UPD. Sorry guys! This work, but problem different, just i use |
FWIW, #14 has dropped support for Node v0.10 and Node v0.12. There are no blockers now that would prevent us from landing an implementation based on cls-hooked. |
Can one of the admins verify this patch? |
@bajtos Sorry for the late response! Luckily, I'm testing this in production right now, and I'll tell you if it works for me ASAP. |
9738804
to
e597ef9
Compare
In that case, let's bump up |
6c8a470
to
f0bb654
Compare
As per suggestion of @bajtos in comment #266030074 in PR strongloop#11
defba32
to
f0bb654
Compare
Hello, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL 👇
npm test | ||
``` | ||
|
||
This adds the `-r` option to `mocha` command, needed in order to pass tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the -r
option to test/mocha.opts
file, so that people can run tests using mocha
directly. I personally use this frequently, e.g. to run only a single test via mocha -g "test name"
.
--require cls-hooked
(BTW you pull request does not change package.json
despite what README says.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see that you already have test/mocha.opts
. I think we should simply remove this section from README then.
@@ -1,9 +1,9 @@ | |||
{ | |||
"name": "loopback-context", | |||
"version": "3.0.0-alpha.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change the version number, we will bump it when releasing a new version.
var asyncFn = function() { | ||
async.waterfall([ | ||
fn1, | ||
fn2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, we usually structure our code differently:
async.waterfall([
function pushToContext(next) {
// code from fn1
},
function pullFromContext(next) {
// code from fn2
},
function verify(next) {
expect(testValue).to.equal('test-value');
next();
},
], done);
See @bajtos comment in PR strongloop#11 strongloop#11 (comment)
Hello, |
@josieusa awesome, thank you for the update! I am not sure if I'll have time to review and land this before I leave for vacation. |
lose a lot of time again. sad. |
@dehypnosis If you want to use this in your app before it gets merged, you can do like this in
If you do this, I strongly recommend to edit |
Rework the module to use the new cls-hooked module (which uses AsyncWrap available since Node v4.5) instead of old continuation-local-storage (based on very unreliable async-listener).
779a5ba
to
996a49f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch looks good to me now. In preparation for landing it, I have cleaned up the commit history and git push -f
to your feature branch.
Landed, thank you for your contribution 🎉 and for keeping the ball rolling despite the long time it took to get this work done 🙇 |
@bajtos i think the version number is confusing since 3.0.0 seems to be related to LB3. I guess this is wrong. After some tests it seems that LB2.x projects should also include loopback-context@3.0.0 to get this changes. |
Yes, you should be able to use
I am afraid it would be similarly confusing if we used 2.0.0, because it would hint relation to LB2. We can improve the documentation though to make this more clear. Can you contribute this change yourself please? @michaelfreund |
@bajtos I totally agree with the version number. Of course i can contribute. What do you think of including related component information in the docs? Like for the context stuff Loopback 3.x BTW http://loopback.io/doc/en/lb3/Using-current-context.html#use-a-custom-strong-remoting-phase seems also working in LB2.x but is missing in the docs. Can you confirm? So i can update that too. |
@michaelfreund sorry for responding late.
I am proposing to add a new section to loopback-context's README with a table similar to
Yes, custom remoting phases are available in LB 2.x too. |
Hello, this is a quick and (not so) dirty alternative to PR #2.
Rationale:
async-listener
, which already was the long-term goal of my previous PR, anyway. Here it just turned into an immediate goal, that's all.continuation-local-storage
withcls-hooked
quitting any attempt to keep backward compatibility with the former, which is exactly what I did in this PR and is the difference with my previous PR. This should make the commitdf60f13
no longer necessary, so I reverted it.cls-hooked
, however (maybecontinuation-local-storage
too, I don't care), needs to be required before everything else, in order to not fail silently and catastrophically. So, I also gave proper and detailed instructions about how to do this in the README.mdAnyway, given the very short time I dedicated to this PR, I would consider this a work-in-progress for now.
TODO:
PS
For now, in order to make tests work, after deleting
node_modules
folder and runningnpm i
, I had to run (NPM v3):I suppose this is because loopback PR #2696 maybe hasn't landed in
loopback-context
yet.Also, for the same reason, if you test this branch from inside a Loopback app, make sure that
loopback-context
uses the same version ofstrong-remoting
as the app.