Correct way to setUser in node sdk?

Hello! I recently added Sentry.setUser in our nodejs integration, and it caused user information to leak across requests into user requests that don’t belong to the current user, likely due to concurrent handling of requests. We’ve removed it for now, but we would like to add this information back.

Based on Add Context for Node.js | Sentry Documentation, I can’t figure out what the correct way is to do this.

  1. Sentry.configureScope(scope => scope.setUser(… seems like it could be right, but now i’m worried that’s going to set a configureScope callback globally, and I’ll be back to the same problem.
  2. I’ve also seen references in sentry sdk code to Sentry.getCurrentHub().getScope(). Would that be better?
  3. Maybe this isn’t handled automatically at all?

What’s the correct way to set user data for the current scope/operation, such that it won’t leak across requests?