clearUserInfo() doesn't clear the cached user id, so baggage keeps the previous user's id
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, react-native, typescript
Hướng nghiên cứu
Bắt đầu từ packages/core/src/sdk/UserInfoSingleton/UserInfoSingleton.ts, nơi clearUserInfo chỉ gán this.userInfo thành undefined, và từ phương thức clearAccountInfo của AccountInfoProvider nằm cạnh đó. Module rum/helper.ts đã export clearCachedUserId và clearCachedAccountId, nhưng chưa có nơi nào gọi chúng. Công việc hoàn thành khi cả hai phương thức clear cũng gọi các helper này, và một test gọi setUserInfo rồi clearUserInfo, kỳ vọng getCachedUserId trả về undefined, chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
DdSdkReactNative.clearUserInfo() doesn't clear the cached user id that resource tracking uses for the baggage header, so after a logout the app keeps sending the previous user's id in baggage on first-party requests.
UserInfoProvider.setUserInfo calls setCachedUserId(userInfo.id) (added in df2b8e68, "Cache userId and accountId when first set"), and RequestContext reads getCachedUserId() to build baggage: user.id=…. But UserInfoProvider.clearUserInfo only resets this.userInfo:
// packages/core/src/sdk/UserInfoSingleton/UserInfoSingleton.ts
clearUserInfo = () => {
this.userInfo = undefined;
};
clearCachedUserId() exists in rum/helper.ts but has no callers. AccountInfoProvider.clearAccountInfo has the same gap with clearCachedAccountId().
The effect is that every traced request after clearUserInfo() (signed-out requests, and the next user's first requests before setUserInfo runs again) carries the previous user's id in baggage. Backends that tag or propagate baggage (e.g. dd-trace's default DD_TRACE_BAGGAGE_TAG_KEYS) then attribute those requests to the wrong user, and may forward the id downstream.
Reproduction steps
- Initialize the SDK with
firstPartyHostsfor a host you control and resource tracking enabled. await DdSdkReactNative.setUserInfo({ id: 'user-a' }), then make a request to that host.baggagecontainsuser.id=user-a(expected).await DdSdkReactNative.clearUserInfo(), then make another request to that host.baggagestill containsuser.id=user-a.
Minimal check without a network request:
UserInfoSingleton.getInstance().setUserInfo({ id: 'user-a' });
UserInfoSingleton.getInstance().clearUserInfo();
getCachedUserId(); // 'user-a', expected undefined
Expected behavior
After clearUserInfo(), baggage omits user.id (the header builder already skips it when the cached id is undefined). Same for account.id after clearAccountInfo().
Suggested fix:
-import { setCachedUserId } from '../../rum/helper';
+import { clearCachedUserId, setCachedUserId } from '../../rum/helper';
...
clearUserInfo = () => {
this.userInfo = undefined;
+ clearCachedUserId();
};
and the equivalent clearCachedAccountId() call in AccountInfoProvider.clearAccountInfo. We're carrying this as a patch-package patch on 3.8.0 for now.
Affected SDK versions
3.0.0 through 3.10.0 (still present on develop)
Latest working SDK version
2.x (no cached user id)
Did you confirm if the latest SDK version fixes the bug?
Yes, checked develop / 3.10.0 and it's still present.
Integration Methods
NPM
React Native Version
0.86.3 (Expo SDK 57)
Other relevant information
Both iOS and Android are affected, since the header is built in the JS request proxy.
- Ngôn ngữ chính
- TypeScript
- Star
- 145
- Fork
- 65
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DataDog/dd-sdk-reactnative
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
DataDog/dd-sdk-reactnative#1497 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[actionNameAttribute] prop doesn't accept value with curly bracesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
DataDog/dd-sdk-reactnative#1486 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Expose Android app startup Activity filtering in the React Native SDKCó thể đã có người làm @sbarrio đã nhận 10 ngày trước. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
DataDog/dd-sdk-reactnative#1485 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
GraphQL variables with non-ASCII contents will make Apollo Client request throw errorCó thể đã có người làm @cdn34dd đã nhận 12 ngày trước. Đang mởawaiting response bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
DataDog/dd-sdk-reactnative#1482 · 2 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Interaction tracking records nothing: the babel plugin's injected import makes Metro bundle a second copy of the SDK, so DdBabelInteractionTracking.config is set on a different class than instrumented handlers callCó thể đã có người làm @cdn34dd đã nhận 10 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
DataDog/dd-sdk-reactnative#1377 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của DataDog/dd-sdk-reactnative
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
simkimsia/netlify-axi#19 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
subhranshudash13-dotcom/Contribo#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement frontend good first issue Stellar Wave trivial
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Godgift-care/sci-healthcare-frontend#166 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue security Stellar Wave trivial
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Godgift-care/sci-healthcare-backend#171 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày