If a navigation is proposed from the native layer after calling resetSession(), and there is more than 1 redirect involved, each of which happens within 500ms of the last, the app breaks. To replicate:
When you click the web navigation link everything works fine (first click in the gif).
When you click the link with slow redirects, everything works fine (second click).
When you click the link that uses the native handler to propose navigation, the navigation fails (third click).
Workarounds
In terms of workarounds: if you don't call resetSesssionshere, the issue is resolved. So the issue only happens when you're on a cold boot path. We need to call resetSessions because in some cases this redirect is been cross-domain and we need to allow that.
Another workaround is adding sleep(0.5) if platform.android? on the server side for this particular code path 😿
This is a hurting my brain, what's the issue?
If you:
Initiate a visit from the native layer
The visit redirects in less than 0.5s to page
Which redirects in less than 0.5s to another page
Then the last visit never happens and you're on a loading indicator forever
An example scenario:
Native layer sets up a session, then navigates to /after_login
/after_login redirects to /posts/current
/posts/current redirects to /posts/2022-03-08
Each of these redirects would need to complete in more than 500ms to avoid the issue.
Possible fix
It'll probably create other issues, but if you remove shouldProposeThrottledVisit or make it return true the issue is resolved. I'm not confident enough about that throttler's purpose to make a PR yet so wanted to get some feedback on the issue.
Another idea would be for shouldProposeThrottledVisit to only happen if there's two attempted to clicks to the same location, not different ones as is the case here.
If a navigation is proposed from the native layer after calling
resetSession()
, and there is more than 1 redirect involved, each of which happens within 500ms of the last, the app breaks. To replicate:Watch this gif:
When you click the web navigation link everything works fine (first click in the gif).
When you click the link with slow redirects, everything works fine (second click).
When you click the link that uses the native handler to propose navigation, the navigation fails (third click).
Workarounds
In terms of workarounds: if you don't call
resetSesssions
here, the issue is resolved. So the issue only happens when you're on a cold boot path. We need to callresetSessions
because in some cases this redirect is been cross-domain and we need to allow that.Another workaround is adding
sleep(0.5) if platform.android?
on the server side for this particular code path 😿This is a hurting my brain, what's the issue?
If you:
An example scenario:
/after_login
/after_login
redirects to/posts/current
/posts/current
redirects to/posts/2022-03-08
Each of these redirects would need to complete in more than 500ms to avoid the issue.
Possible fix
It'll probably create other issues, but if you remove
shouldProposeThrottledVisit
or make itreturn true
the issue is resolved. I'm not confident enough about that throttler's purpose to make a PR yet so wanted to get some feedback on the issue.Another idea would be for
shouldProposeThrottledVisit
to only happen if there's two attempted to clicks to the same location, not different ones as is the case here.