-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent duplicate requests on network failure #18237
Conversation
@johnmlee101 @Santhosh-Sellavel One of you needs to 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] |
@jjcoffee Can you update web & desktop screens as well? |
@Santhosh-Sellavel Not sure where the web one disappeared to! I've added both now. |
@jjcoffee I'm still getting the error here, did we miss something here? Screen.Recording.2023-05-03.at.6.49.37.AM.mov |
@Santhosh-Sellavel Hmm I actually think that's a slightly different issue, as the I was only able to get this behaviour (request actually failing) when going offline very close to sending the attachment - it's actually pretty hard to replicate (for me at least!). The original fix deals with a slightly different behaviour of waiting a bit before going offline, which means the request actually succeeds, but we generate an additional request anyway. |
@jjcoffee Try with a file 20 mb, use slow 3g initially instead of no throttling it's easy to reproduce. |
@Santhosh-Sellavel That's what I've been trying, it's not consistent for me at all (I can't get it to happen right now, for example). More often than not I get the request stuck on "pending" or completing whilst offline, rather than it actually failing as in your case. Could there be anything else specific you're doing? |
@Santhosh-Sellavel Also just to rule out anything specific with your setup, can you also reproduce the behaviour I'm fixing here, where the request doesn't fail but succeeds whilst offline? |
@Santhosh-Sellavel I've been trying a bunch of times and I definitely can't repro very often (maybe 1/50 times or something). I suspect this may be therefore more of an edge case, as both the reproductions on the issue have the behaviour that the request succeeds. |
There is a more straight-forward way here check the below video Screen.Recording.2023-05-03.at.9.23.35.PM.mov |
@Santhosh-Sellavel Oh this was a fun one! I still can't replicate consistently on Chrome (Linux), but I finally can repro on Firefox (actually with both methods). In short I have pushed a new commit that fixes the type of behaviour you're experiencing when going offline (the API request failing), whilst maintaining the fix for the one I was getting mostly (where the request succeeds). Full rationale for the changes below! For the case where the request actually fails, we can't really know why it failed from the FE so I think it's correct behaviour to retry the request here. So I propose that we still run the second I think it's reasonable to expect that |
@Santhosh-Sellavel I've merged main back into this PR per this Slack message, and also retested across the devices that are possible for me to (so just missing iOS). For Chrome Desktop I figured out that disabling the server (via exiting the |
@Santhosh-Sellavel Updated the JSON_CODE to be more generic, so ready for re-review. Thanks! |
Screenshots/VideosWebScreen.Recording.2023-05-11.at.11.15.54.PM.movMobile Web - ChromeScreen.Recording.2023-05-09.at.11.29.40.PM.movDesktopScreen.Recording.2023-05-09.at.11.24.09.PM.movAndroidScreen.Recording.2023-05-09.at.11.35.07.PM.mov |
@johnmlee101 LGTM, I will get done with the checklist & web recording by tomorrow, thanks! |
Awesome, let me know when that's done and I'll do a final pass review! |
There was a small merge conflict (just a formatting tweak in |
Reviewer Checklist
Screenshots/Videos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tests well!
All yours @johnmlee101
Not sure what went wrong earlier, the web platforms also work now for me. |
Congrats, that’s your 5th PR merged! 🎉 Do you know about the ContributorPlus role? It’s an opportunity to earn more in the Expensify Open Source community. Keep up the great work - thanks! |
✋ 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/johnmlee101 in version: 1.3.14-0 🚀
|
Tested and works on staging |
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.3.14-14 🚀
|
Details
The
Reauthentication
middleware was blocking requests fromSequentialQueue
from completing if the user was offline just as the request completes, which causedSequentialQueue
to create a duplicate request and an ugly technical error on the FE as a result.Fixed Issues
$ #16637
PROPOSAL: #16637 (comment)
Tests
For testing on Chrome:
AddAttachment
API request to completeNo throttling
)AddAttachment
API request should show in the network requests tab, and the ugly technical error should show in the report.Local testing with mobiles can be done as above but switching WiFi on the phone off/on. For Android, make sure to run with
adb reverse
, e.g.adb reverse tcp:8080 tcp:8080
(or whatever your config is).Offline tests
N/A
QA Steps
Same as above.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
new-network-chrome-desktop-2023-05-05_12.10.57.mp4
Mobile Web - Chrome
new-network-chrome-android.mp4
Mobile Web - Safari
Desktop
new-network-mac-desktop-2023-05-05_12.10.57.mp4
iOS
Android
new-network-android-native.mp4