-
Notifications
You must be signed in to change notification settings - Fork 207
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
Value persists in cls namespace even when http request has ended #65
Comments
I'm having exactly the same issue. |
Hi @stnever. Can you post the complete code? i.e. in what context you're running the It sounds like the cache code is being run out of context i.e. is writing the cache to the "root" CLS context, rather than within the context of the request. Hence why it then persists across different requests. Combining CLS with promises gets complicated. (see #64 if you want to nerd out about it!) |
@stnever |
By the way, I'd recommend using cls-bluebird if you're using CLS with Bluebird promises. I did a big rewrite of it and it's more reliable than the Sequelize shim. cls-bluebird has got 100,000 tests for god's sake! Concerning this issue, I don't think the OP ever gave enough detail to understand where the problem is coming from. If you're also having this problem @stnever maybe post a more complete example? |
Oops, sorry for the delay! I'm afraid the portion of code where this was happening was refactored a while ago, and I didn't get around to building a completely reproducible example. At any rate, I'm no longer seeing this problem. I'll check cls-bluebird, thanks! |
OK if you're also having this problem @mariodu maybe post a more complete example? |
Hi! I'm using the usual method to have CLS contexts per http request:
I'm using the Sequelize Bluebird shim to have CLS play nicely with Promises.
On a certain request, I pre-populate a cache and store it in the namespace:
The thing is, I thought that
allConfigs
property would disappear when the HTTP request ended (that cache is intended to be used by several pieces of business logic, but on the same request). What I'm seeing is, that once the first request populates the cache, other requests detect it and I end up always using stale data.Is this the correct behaviour? Should I manually clear the namespace before every request?
The text was updated successfully, but these errors were encountered: