Javascript Context

I had a question about the docs regarding setting context.

Per the docs

Sentry.configureScope((scope) => {
  scope.setUser({"email": ""});

I am using


The user information I have is attached to the request via a JWT and that is where I will get the data for setting context.

Do i need to call configure scope in an app.use?
Since Javascript is single threaded, I want to make sure the context is to the current request.

My fear:
User 1 makes http call and configureScope is called
User 1 calls the db and waits a few seconds
User 2 During this time makes an http call and it calls configure Scope
User 1 DB throws an exception and goes to log, but is logged now with User 2’s context.

How do I avoid this scenario using Sentry and Express. This was not clear in the docs since all the examples had hard coded objects.



Since express is using domains and we internally handle them correctly, you should be able to just call configureScope in every request.
The scope in every request will be isolated.
If you are calling configureScope globally not within a request, it will be set for every request.

Hope this helps.