-
Notifications
You must be signed in to change notification settings - Fork 3k
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
HttpUtils abortable requests #6388
Conversation
Another interesting case where aborting requests can help is aborting and retrying pending requests after reauthentication Typical requests when the app is launched with an expired auth token
The 🟧 requests are rejected with expired token which:
Also note the horizontal grey bars - they represent stalled requests - these are request that Chrome received (our xhr calls), but is too busy to process right now, Chrome allows for up to 6 http 1.1 requests (connections) running at once, other requests would wait to enter the pool - in other words they would only wait to fail due to the expired token How aborting would help is
We should take care to abort only the requests that use an
|
d315343
to
1be0a68
Compare
I'm marking this ready so that someone can take a look and decide if it's worth it |
Add functionality to let requests be aborted Abort any leftover requests during sign out
1be0a68
to
3dffba0
Compare
It seems to work when I test it. But I'm a bit new at this so I think it'd be good to have another set of eyes. @marcaaron @aldo-expensify @Julesssss looks like you all weighed in on the issue. Any of y'all want to take a look and give an opinion? |
Unfortunately I'm unable to dedicate any time here. Looks like a potentially cool idea, but I'm not sure whether we need to do it and the changes are pretty low level which means we will need to be careful in evaluating and merging them. I'm hesitant in general to change much about the lower level networking stuff at this particular moment in time. The network stuff could really use a refactor or something before adding new features or complexity (to be clear, this doesn't seem crazy complex - just unsure what problem we are trying to solve or if many people are affected by it). |
The original issue that this PR solves expired
There's no way to make requests abortable without providing a I don't think the change here would affect the app much - existing and future usages of Another reason we need a kill switch like this are tickets dealing with background tasks like
Background tasks on iOS are allowed to run for 30 sec. Exceeding this limit would make the os force close the app let isTimeout = event.timeout; // <-- true when your background-time has expired.
if (isTimeout) {
// This task has exceeded its allowed running-time.
// You must stop what you're doing immediately finish(taskId)
console.log('[BackgroundFetch] Headless TIMEOUT:', taskId);
BackgroundFetch.finish(taskId);
return;
} So a functionality like BTW with the other change that clears requests from persisted storage (after they're completed), we will just send the remaining requests (including retrying the aborted one) on the next run |
Hey @kidroca. If you still think this would be good for us to do, I think the ideal thing to do would be take this back to #expensify-open-source and start a discussion there. Then we can decide on whether to move forward. Thanks! |
Thanks for the reply @puneetlath |
Details
Add functionality to let requests be aborted
Abort any leftover requests during sign out
Fixed Issues
$ #2642
Tests
All platforms
Mobile
Similar to the steps above - we're trying to have pending requests when we log out
On Android, there are throttling options in the Emulator network settings
On iOS there aren't but it's still possible (see the attached video):
QA Steps
See if you can do any of the Tests above
If not, try to log in and then log out as fast as possible, there should be no weird behavior afterwards
Tested On
Screenshots
Web
Screen.Recording.2021-11-22.at.12.26.02.mov
Mobile Web
Desktop
iOS
Screen.Recording.2021-11-21.at.22.07.12.mov
Android