Repository navigation
hotfix(publicroom):Avoid crash on undefined state - #20772
Conversation
7d960c3 to
2332530
Compare
WoLewicki
left a comment
There was a problem hiding this comment.
I think it's ok to leave both guards in case there are more flows that would use it, but at the same time I would really like to know why the undefined state ends up in this function at all.
|
For sure @WoLewicki (& @mountiny) it occurs in this line https://github.com/react-navigation/react-navigation/blob/7d8b5156dff9a0c6a5ddca6c15dc7e5c65e94bec/packages/core/src/BaseNavigationContainer.tsx#L385 here |
|
For more context. first time it enters that useEffect inside react navigation, hydratedState DOES have information:"['Home', 'TransitionFromOldDot', 'ValidateLogin', 'UnlinkLogin']". Second time it enters it returns undefined. Next time(Third), it has the whole route: "['Home', 'CentralPaneNavigator', 'ValidateLogin', 'TransitionFromOldDot', 'Concierge', 'FullScreenNavigator', 'RightModalNavigator']". My hypothesis is that, since we have the 2 stack architecture, during the transition of last state, sign in page, to the state of anonymous report. Same as transition between Public to Auth screens at some point the rootState is just undefined. That's as deep as I can get without having worked much with the library. @WoLewicki |
WoLewicki
left a comment
There was a problem hiding this comment.
Ok thanks for your explanation and digging into it! Yeah, if it is just how the navigation works under the hood when switching the stacks underneath, and at the same time we are sure that after the undefined state, there comes the correct one, I think we can leave it as it is
|
FYI @adamgrzybowski here is the explanation of why it is undefined. @marcochavezf FYI maybe it is a difference between the login access and the anonuser access after SignInPage. |
|
@mollfpr Will you be able to get this one? |
mountiny
left a comment
There was a problem hiding this comment.
Thanks @daordonez11 Really loving that you have dug deep to understand the issue here 🚀
Lets wait for C+ to test this properly before merging.
|
@daordonez11 I see your web recording has not uploaded correctly, could you please fix that? Also regarding Android native, what if you click the native back instead of browser back? |
|
Thanks! |
|
Testing now. |
Reviewer Checklist
Screenshots/VideosWeb20772.Web.movMobile Web - Chrome20772.mWeb.Chrome.webmMobile Web - Safari20772.mWeb.Safari.mp4DesktopN/A iOSN/A AndroidN/A |
mountiny
left a comment
There was a problem hiding this comment.
thanks everyone, really appreciate it!
|
✋ 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/mountiny in version: 1.3.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.31-3 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.31-3 🚀
|
| * @returns {String | undefined} - It's possible that there is no report screen | ||
| */ | ||
| function getTopmostReportId(state) { | ||
| if (!state) { |
There was a problem hiding this comment.
Why do we need to add this condition here?
There was a problem hiding this comment.
@parasharrajat we found a case where state could arrive undefined . This is to avoid issues in the future where this functions is called and we don't know the specific value of state that could arrive.

Details
Avoid application crash when navigationRef state is undefined
Fixed Issues
$ #20825
PROPOSAL: #20825 (comment)
Tests
3 .Send a message in the room (important step)
Offline tests
N/a
QA Steps
Same as tests
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 */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)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
Web
Fixed.Browser.Recording.webm
Mobile Web - Chrome
Mobile.Browser.-.14_6_2023.14_55_36.webm
Mobile Web - Safari
safari.browser.working.6-20.mp4
Desktop
N/A Public rooms not supportediOS
N/A Issue only reproducible in browser
Android
N/A Issue only reproducible in browser