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

session lost after bluebird.delay #140

Open
joniba opened this issue Mar 15, 2019 · 2 comments
Open

session lost after bluebird.delay #140

joniba opened this issue Mar 15, 2019 · 2 comments

Comments

@joniba
Copy link

joniba commented Mar 15, 2019

I'm trying to integrate cls into an existing project running both async/await and bluebird. Everything works terrific, until bluebird.delay is called, at which point the session gets lost. Example code:

var Promise = require('bluebird');
var cls = require('continuation-local-storage');
var session = cls.createNamespace('blah');

session.run(async () => {
    session.set('one', 1);
    await Promise.resolve().delay(1);
    console.log(`========== one: ${cls.getNamespace('blah').get('one')} ==========`);
})

Help would be greatly appreciated

@carlisliu
Copy link

replace
var cls = require('continuation-local-storage');
with
var cls = require('cls-hooked');

@skrosoft
Copy link

skrosoft commented Sep 6, 2020

Thank you so much @carlisliu, I had the same problem with TypeORM 👍

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