Skip to content

chore: do not fetch backend metadata when loading user session - WPB-24411#4513

Open
samwyndham wants to merge 25 commits intochore/do-not-check-blacklist-loading-user-session-WPB-24175from
chore/do-not-fetch-backend-metadata-loading-user-session-WPB-24411
Open

chore: do not fetch backend metadata when loading user session - WPB-24411#4513
samwyndham wants to merge 25 commits intochore/do-not-check-blacklist-loading-user-session-WPB-24175from
chore/do-not-fetch-backend-metadata-loading-user-session-WPB-24411

Conversation

@samwyndham
Copy link
Copy Markdown
Contributor

@samwyndham samwyndham commented Mar 31, 2026

TaskWPB-24411 [iOS] Don't fetch backend metadata as part of loading user session

Issue

This PR decouples fetching background metadata from loading the user session. The idea behind this effort is to not block the user from launching the app - under bad network conditions the user might wait 1 minute until a network request times out.

Instead this PR introduces a Worker that will attempt to fetch the latest background metadata at various intervals and store that metadata on disk. The new metadata will only be used the next time the user session is loaded.

This affects the API version used and whether federation is used. In practice I don't think this should be an issue. API versions are generally not deprecated immediately and on the rare occasion of switching from a non federated to federated setup, I believe the behavior is the same as if federation was enabled while the application was already running - we wouldn't get the change until the next app launch. An improvement, not included in this PR could be to have this work also done as a background task.

I did discuss what happens on Android. There the request is also not tied to the loading of the user session. However with their setup I believe when the request is made and changes detected, those changes will take effect immediately. I expect this would be hard to achieve on iOS though.

Testing

Test fetching API version doesn't block user

  1. Login to staging & quit
  2. Using a proxy, block requests to https://staging-nginz-https.zinfra.io/api-version.
  3. Start the app.
  4. The app should open to the conversation list without waiting 60 seconds for the api version request to timeout.

Test migrating API version

  1. Fresh install
  2. Using a proxy, edit the response of https://staging-nginz-https.zinfra.io/api-version so that it returns a previous API version as the latest. (for example lets assume the real latest is v14 and we make the response return v13)
  3. Login to staging
  4. Check the API version used is v13
  5. Quit the app
  6. Stop the proxy
  7. Open the app and check API version - it should still be v13
  8. Quit the app
  9. Open the app and check API version - it should now be v14

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

import WireLogging
import WireNetwork

open class AuthenticatedSessionFactory {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is no longer used

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗑️

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was dead code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was dead code

}

// Get new metadata.
// Otherwise fetch and store new metadata.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work is now only done here if we don't have some existing backend metadata. Fetching the latest now happens elsewhere - in a Worker

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit aa852bd.

♻️ This comment has been updated with latest results.

Summary: workflow run #23787807022
Allure report (download zip): html-report-28908-chore_do-not-fetch-backend-metadata-loading-user-session-WPB-24411

@sonarqubecloud
Copy link
Copy Markdown

@samwyndham samwyndham requested review from johnxnguyen and netbe and removed request for johnxnguyen April 1, 2026 06:18
Copy link
Copy Markdown
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good,

just one question: I am a bit confused about the different systems we have at the moment and to which one is going away vs staying.

Could you clarify usage and future of following?

  • RecurringActionService
  • Worker
  • WorkAgent

import WireLogging
import WireNetwork

open class AuthenticatedSessionFactory {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗑️

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.

2 participants