-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Context lost after mysql query #15
Comments
Thanks for the feedback 👍 What are the current versions of node, npm, and your operating system? |
Ubuntu: Hope that helps 🙂 |
Same behaviour for mongoose osx: 10.14 |
Any answers for this?? |
Just tested with following: osx:
looks like context isn't lost after mysql queries, works fine for me 🤓 I'm not sure, why, though. I use async-await everywhere across my code, mysql is used internally by TypeORM. |
Same behaviour for mysql OS: But new mysql connection everytime will works 😏: app.get('/', (req, res) => {
const connection = mysql.createConnection({ xxx })
const connection.connect()
connection.query(SQL, (err, result, fields) => {
httpContext.get('xxx') // it will works
})
})
`` |
I fixed it with util.promisify(connection.query).bind(connection)('SELECT * FROM some.table')
.then((result, fields) => {
console.log(httpContext.get('foo')); // prints bar
})
.catch(error => {}); |
I'm trying to get http context after a mysql query in express app. The context seems to be lost after executing a query:
Please help
The text was updated successfully, but these errors were encountered: