Skip to content
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

Stop "retrying" requests that fail in the main queue #8860

Merged
merged 8 commits into from
May 26, 2022

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented May 3, 2022

Details

Holding on:

Fixed Issues (Related to)

https://github.com/Expensify/Expensify/issues/208281

Tests

  1. Block a the UpdateLastRead request that is triggered whenever a report is switched to (see tip here)
  2. Navigate to a report while online
  3. Verify that the request is not getting retried at all and doesn't throw any errors in the JS console
  • Verify that no errors appear in the JS console

PR Review Checklist

PR Reviewer Checklist

  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there’s a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained “why” the code was doing something instead of only explaining “what” the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named “index.js”. All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn’t already exist
    • The style can’t be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

Screenshots

…ts - stop queueing read requests. watch many tests fail
@marcaaron marcaaron self-assigned this May 3, 2022
Base automatically changed from marcaaron-pushToSequentialQueue to main May 3, 2022 21:41
@marcaaron marcaaron changed the title [HOLD + WIP] Stop queuing read requests [HOLD + WIP] Stop queuing read requests. Banish shouldRetry. Stop retrying non-retryable requests. May 4, 2022
@marcaaron marcaaron changed the title [HOLD + WIP] Stop queuing read requests. Banish shouldRetry. Stop retrying non-retryable requests. [HOLD] Stop queuing read requests. Banish shouldRetry. Stop retrying non-retryable requests. May 4, 2022
@marcaaron marcaaron changed the title [HOLD] Stop queuing read requests. Banish shouldRetry. Stop retrying non-retryable requests. [HOLD] Stop queuing non-retryable requests. Banish shouldRetry. May 4, 2022
@marcaaron
Copy link
Contributor Author

marcaaron commented May 4, 2022

Realizing that an interesting side effect of the original changes (now reverted) would be that all things are technically "retryable" and optimistic (but not persistent) and will not be optimistic anymore after.

We would be able to fix that by making any optimistic requests have a persist: true, but in the doc we decided this would be a gradual process. Report comments are the only thing that will work with this new system at the moment.

@marcaaron
Copy link
Contributor Author

Gonna expand on this problem because on further reflection I don't think we can actually get rid of shouldRetry until all optimistic (but not persisted) actions are refactored over to the new API system being proposed in this thread.

We can still kill the "retry counter" logic though for things outside of the Sequential Queue.

Current behavior:

  • Write request (w/o persist: true) is made while we are offline
  • It goes into the main queue because we are offline and stays there because it’s “retryable” (actually all requests are retryable unless we specify that they are not)
  • Come back online and the main queue will process again (basically giving us the same “optimistic” behavior, but without the “persistance” that report comments have)

Gonna make those changes now so I can merge the good parts of this and wrap up the Network Improvements project as the retry logic is holding on the API changes.

1 similar comment
@marcaaron

This comment was marked as duplicate.

@marcaaron marcaaron changed the title [HOLD] Stop queuing non-retryable requests. Banish shouldRetry. [HOLD] Stop "retrying" requests that fail in the main queue May 17, 2022
@marcaaron marcaaron changed the title [HOLD] Stop "retrying" requests that fail in the main queue Stop "retrying" requests that fail in the main queue May 17, 2022
@marcaaron marcaaron marked this pull request as ready for review May 17, 2022 02:24
@marcaaron marcaaron requested a review from a team as a code owner May 17, 2022 02:24
@melvin-bot melvin-bot bot requested review from PauloGasparSv and removed request for a team May 17, 2022 02:24
@marcaaron marcaaron requested a review from roryabraham May 17, 2022 02:39
@marcaaron
Copy link
Contributor Author

@roryabraham adding you here to have a second set of eyes and my rambling comments above might be interesting to you

@marcaaron
Copy link
Contributor Author

Bump

@roryabraham
Copy link
Contributor

LGTM 👍

Leaving a brief summary to explain the reasoning for why we're making this change... Basically:

  • Requests that can be saved and retried later belong in the sequential (persisted) queue. Only writes fit in this category
  • If any other (non-persistable) requests fail in flight, the solution is to handle that gracefully, not to retry it without a basis or understanding for why it failed.

@roryabraham roryabraham merged commit 5058236 into main May 26, 2022
@roryabraham roryabraham deleted the marcaaron-stopQueuingReadRequests branch May 26, 2022 01:45
@marcaaron
Copy link
Contributor Author

What @roryabraham said + also want to quickly document that a consequence of this change is that some quasi-optimistic writes that kind of work offline will be broken by this change in a very minor way and only in the situation where we suddenly go offline or the site is down.

Offline features for these requests will still mostly work while you are offline. We just will stop handling that edge case for all commands (except Report_AddComment since it is in the SequentialQueue). Ultimately, we are going to rip this code out anyway and will be more explicit in the future about which things will be retried and which will not.

This will also free up @madmax330 to focus on the retry changes for the SequentialQueue without having to consider a system where both reads and writes could be retried on failure.

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @roryabraham in version: 1.1.68-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.68-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

2 similar comments
@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.68-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.68-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@Julesssss
Copy link
Contributor

Please ignore these duplicated messages, we only deployed once but the message appears each the iOS deploy fails.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.68-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

1 similar comment
@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.68-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants