[NoQA] Add logs to help debug a NotFound issue#79689
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MarioExpensify Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| }, | ||
| [ownerAccountID], | ||
| ); | ||
| const [ownerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: ownerPersonalDetailsSelector, canBeMissing: true}, [ownerPersonalDetailsSelector]); |
There was a problem hiding this comment.
❌ PERF-11 (docs)
The useOnyx hook is being called with the entire PERSONAL_DETAILS_LIST collection, but only a single personal detail entry (for ownerAccountID) is needed. This causes the component to subscribe to changes for ALL personal details in the system, leading to unnecessary re-renders whenever any user's personal details change.
Suggested fix:
Use a more specific Onyx key that targets only the owner's personal details:
const ownerPersonalDetailsKey = `${ONYXKEYS.PERSONAL_DETAILS_LIST}${ownerAccountID}` as const;
const [ownerPersonalDetails] = useOnyx(ownerPersonalDetailsKey, {canBeMissing: true});If the collection pattern is required, consider using allowStaleData: true to reduce re-render frequency.
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
| const prevShouldShowAccessErrorPage = usePrevious(shouldShowAccessErrorPage); | ||
| const participantCount = Object.keys(report?.participants ?? {}).length; | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Not sure if this is a real problem because I see this pattern a lot but it still concerns me. Does usePrevious works as expected when we use its value inside another hook?
Here is what I'm thinking
Render phase:
shouldShowAccessErrorPageis falseprevShouldShowAccessErrorPageis undefined
Side-effects phase:
- useEffect (inside usePrevious) updates
prevShouldShowAccessErrorPageto false - useEffect (the checker) returns early because
shouldShowAccessErrorPageis false
Render phase 2:
shouldShowAccessErrorPageis trueprevShouldShowAccessErrorPageis false
Side-effects phase 2:
- useEffect (inside usePrevious) updates
prevShouldShowAccessErrorPageto true - useEffect (the checker) returns early because
prevShouldShowAccessErrorPageis true
And we don't end up sending the log? Or am I missing something?
There was a problem hiding this comment.
@s77rt closures capture values at render time, not effect time.
RENDER PHASE:
shouldShowAccessErrorPage = trueusePrevious(true)called -> butref.currentis stillfalse(effect from render 1 set it)prevShouldShowAccessErrorPage = false(captured in effect closure)
EFFECT PHASE:
usePreviouseffect runs first:ref.current = true- Logging effect runs with closure values from render:
shouldShowAccessErrorPage=true, prevShouldShowAccessErrorPage=false - Condition: !true || false = false -> log is sent
prevShouldShowAccessErrorPage is false not undefined, as it initializes with useRef<T>(value).
I've created a code sandbox to illustrate it: https://codesandbox.io/p/sandbox/zl53xr
There was a problem hiding this comment.
Thank you! That makes sense. In the effect we modified the ref value but the value we have in hand was captured before and that internal change does not affect us.
|
Don't think we need a product review on a logging PR, unassigned myself 👍 |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
NotFound issueNotFound issue
| return; | ||
| } | ||
|
|
||
| Log.info('[SearchMoneyRequestReportPage] shouldShowAccessErrorPage changed to true', false, { |
There was a problem hiding this comment.
let's keen an eye on this to see how often this log happens?
|
FWIW, the bug may have been caused by |
Let's see if we have any other occurrences of this bug; otherwise, it's likely the cause. I still think these logs will help us down the line for tricky bugs 😄 |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.3.5-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.3.5-7 🚀
|

Explanation of Change
Add logs to help debug a
NotFoundissueContext
Fixed Issues
$ #77575
PROPOSAL:
Tests
NA, it's just logs added
Offline tests
NA
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
NA, it's just logs added
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari