Skip to content

using environment variable set by Environment.js for ios/android#12546

Closed
smrutiparida wants to merge 3 commits into
Expensify:mainfrom
autosave-app:staging_url
Closed

using environment variable set by Environment.js for ios/android#12546
smrutiparida wants to merge 3 commits into
Expensify:mainfrom
autosave-app:staging_url

Conversation

@smrutiparida

@smrutiparida smrutiparida commented Nov 8, 2022

Copy link
Copy Markdown
Contributor

@mountiny @parasharrajat @AndrewGable

Details

The issue occured as a regression for ios/android apps for PR # 10690. Despite setting shouldUseStagingServer preference by the User, the staging URL was not getting picked up by the apiRoot to call the API in ios and android staging builds.

The reason for this was, ENVIRONMENT variable from .env config is used to set IS_STAGING variable. For ios/android this variable was always set as PRODUCTION due to the present Fastlane build process

The fix was to dynamically deduce the environment by calling Environment.getEnvironment() promise instead of using IS_STAGING variable.

For web/desktop the function reads the config as you said in libs/Environment/getEnvironment/index.js.

function getEnvironment() {
    return Promise.resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV));
}

For Native, the function in libs/Environment/getEnvironment/index.native.js additionally does a isBetaBuild() check. See below. The isBetaBuild compares the pkg.version with the Google Play Store version and accordingly sets isBeta flag. iOS does the same check using NativeModules.EnvironmentChecker check for iOS devices.

if (lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV) {
      environment = CONST.ENVIRONMENT.DEV;
      return resolve(environment);
  }

// If we haven't set the environment yet and we aren't on dev, check to see if this is a beta build
betaChecker.isBetaBuild()
    .then((isBeta) => {
        environment = isBeta ? CONST.ENVIRONMENT.STAGING : CONST.ENVIRONMENT.PRODUCTION;
        resolve(environment);
    });

Fixed Issues

$ #11561

Tests

  1. Introduce a console.debug(shouldUseStagingServer is ${shouldUseStagingServer}, environment is ${environment} and apiRoot is ${apiRoot}); code in the changed code.
  2. Change the version in package.json to 1.2.25-1
  3. in iOS device, install the app via testflight for isBeta to work
  4. Run the below QA steps

Expectation is that the environment based apiRoot shall be logged in console.

  • Verify that no errors appear in the JS console

QA Steps

  1. Settings -> Preference -> Use staging server = ON along with ENVIRONMENT=staging in .env
    - Open app on web
    - Go to Settings -> Preference
    - Make the Use staging server switch ON
    - Open dev tool
    - Go to Network tab.
    - Focus on app and send some message.
    - Verify that the request in Fetch/XHR is of staging server https://staging.expensify.com or https://staging-secure.expensify.com.

  2. Settings -> Preference -> Use staging server = OFF along with ENVIRONMENT=staging and USE_WEB_PROXY=true in .env
    - Open app on web
    - Go to Settings -> Preference
    - Make the Use staging server switch OFF
    - Open dev tool
    - Go to Network tab.
    - Focus on app and send some message.
    - Verify that Fetch/XHR is of production server (without staging prefixes) to / ( ideally it should have gone to new.expensify.com by with useWebProxy it will be sent to / to avoid CORS error)

  3. Settings -> Preference -> Use staging server = ON along with ENVIRONMENT=development in .env
    - Open app on web
    - Go to Settings -> Preference
    - Make the Use staging server switch OFF
    - Open dev tool
    - Go to Network tab.
    - Focus on app and send some message.
    - Verify that Fetch/XHR is of production server (without staging prefixes) https://www.expensify.com or https://secure.expensify.com.

  4. Settings -> Preference -> Use staging server = OFF with no .env file
    - Open app on web
    - Go to Settings -> Preference
    - Make the Use staging server switch OFF
    - Open dev tool
    - Go to Network tab.
    - Focus on app and send some message.
    - Verify that Fetch/XHR is of production server (without staging prefixes) to / ( ideally it should have gone to new.expensify.com by with useWebProxy it will be sent to / to avoid CORS error)

  5. Settings -> Preference -> Use staging server = ON along with ENVIRONMENT=production in .env
    - The Preference will not be visible in the UI

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover 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 included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed 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 followed proper code patterns (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 adding the Waiting for Copy label for a copy review 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 followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • 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 */
    • 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • 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 included screenshots or videos 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
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 adding the Waiting for Copy label for a copy review 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 other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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 */
    • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots

Web

Test Case 1:
Screenshot 2022-11-09 at 4 03 18 PM

Test Case 2:
Screenshot 2022-11-09 at 4 05 38 PM

Mobile Web - Chrome

Test Case 2:

screenrecord.mov

Mobile Web - Safari

Test Case 4:

Screenshot 2022-11-09 at 4 35 14 PM

Desktop

TestCase 4:
Screenshot 2022-11-09 at 5 06 04 PM

iOS

Screenshot 2022-11-09 at 8 10 50 PM

Android

TestCase 1:
Part 1 video

part1.mov

Part 2 video

part2.mov

@smrutiparida smrutiparida requested a review from a team as a code owner November 8, 2022 09:16
@melvin-bot melvin-bot Bot requested review from mountiny and parasharrajat and removed request for a team November 8, 2022 09:16

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@smrutiparida Would you be able to also include screenshots/videos of the platforms confirming everything works as expected and ideally showcase the QA steps with the console.debug output showing this is working as expected in your local environment?

Thanks for raising this PR quickly.

Comment thread src/libs/HttpUtils.js Outdated
Comment thread src/libs/HttpUtils.js Outdated
Comment thread src/libs/HttpUtils.js Outdated

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@smrutiparida The code looks fine to me but could you please included screen recording of the console with debug and whats in the .env so we can see this works for you as expected.

Then you can fill in the PR author checklist for other platforms too so it passes

@smrutiparida

Copy link
Copy Markdown
Contributor Author

@smrutiparida The code looks fine to me but could you please included screen recording of the console with debug and whats in the .env so we can see this works for you as expected.

Then you can fill in the PR author checklist for other platforms too so it passes

Done now. Please see the Android video

@smrutiparida

Copy link
Copy Markdown
Contributor Author

recheck

@mountiny

mountiny commented Nov 9, 2022

Copy link
Copy Markdown
Contributor

Thank you very much @smrutiparida fixed the PR author checklist.

Gonna wait a bit for the review from Rajat

@parasharrajat

Copy link
Copy Markdown
Member

Thanks for waiting. I will try to get on it. If not, I will inform the same.

@mountiny

Copy link
Copy Markdown
Contributor

@parasharrajat let me know if you can get to this on Monday, if not, feel free to use the two new C+ to re-assign for testing/review. Thanks!

@parasharrajat

Copy link
Copy Markdown
Member

I will be back in 2 hours and review this.

@parasharrajat

Copy link
Copy Markdown
Member

Back so checking now.

@parasharrajat

parasharrajat commented Nov 14, 2022

Copy link
Copy Markdown
Member

Should QA steps 3 and 4 call the development API? @mountiny

@mountiny

Copy link
Copy Markdown
Contributor

@parasharrajat I think QA 4 is production right? QA3 seems like development, I can confirm this works.

@parasharrajat

Copy link
Copy Markdown
Member

Under some discussion...

@mountiny

mountiny commented Nov 14, 2022

Copy link
Copy Markdown
Contributor

@parasharrajat can you point to the discussion if it is other than the one in the Slack?

Other than this https://expensify.slack.com/archives/C01GTK53T8Q/p1668446333318199 which seems resolved.

Comment thread src/libs/HttpUtils.js
// Additionally, for iOS/android betaChecker.isBetaBuild() does the version check
// environment is initialized as null as the default set in CONFIG.js always takes precedence
let environment = null;
Environment.getEnvironment()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this function read a different Config from what we have in env which was used to build the app?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still do not get it. Why getting the value here is different from Config.js file?

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.

@parasharrajat

For web/desktop the function reads the config as you said in libs/Environment/getEnvironment/index.js.

function getEnvironment() {
    return Promise.resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV));
}

For Native, the function in libs/Environment/getEnvironment/index.native.js additionally does a isBetaBuild() check. See below. The isBetaBuild compares the pkg.version with the Google Play Store version and accordingly sets isBeta flag. iOS does the same check using NativeModules.EnvironmentChecker check for iOS devices.

if (lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV) {
      environment = CONST.ENVIRONMENT.DEV;
      return resolve(environment);
  }

// If we haven't set the environment yet and we aren't on dev, check to see if this is a beta build
betaChecker.isBetaBuild()
    .then((isBeta) => {
        environment = isBeta ? CONST.ENVIRONMENT.STAGING : CONST.ENVIRONMENT.PRODUCTION;
        resolve(environment);
    });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@smrutiparida Thanks for the explanation, can you also include this in the PR body?

@parasharrajat parasharrajat Nov 15, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, I got it. Yeah, please add it to the details. I read all of the comments on the issue and PR, it does not explain why are we doing this change and how this works.

Comment thread src/libs/HttpUtils.js
Comment on lines +22 to +24
// getEnvironment promise returns the environment based on ENVIRONMENT Config for web/desktop.
// Additionally, for iOS/android betaChecker.isBetaBuild() does the version check
// environment is initialized as null as the default set in CONFIG.js always takes precedence

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// getEnvironment promise returns the environment based on ENVIRONMENT Config for web/desktop.
// Additionally, for iOS/android betaChecker.isBetaBuild() does the version check
// environment is initialized as null as the default set in CONFIG.js always takes precedence
// `getEnvironment` returns the environment based on .env Config for web/desktop.
// Additionally on iOS/android beta is checked to get the runtime Environment.

Comment thread src/libs/HttpUtils.js
// environment is initialized as null as the default set in CONFIG.js always takes precedence
let environment = null;
Environment.getEnvironment()
.then((env) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a problem with this change. It might not work always. requests are made in promises and you are trying to get the env info outside the promise chain.

It is possible that for some requests ENV is not yet.

@smrutiparida smrutiparida Nov 16, 2022

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.

Do you suggest to then await like below.

const environment = await Environment.getEnvironment();

The only issue with await was it shall make the xhr execution wait in HttpUtils till promises returns a value. This may slow down the app starting in android environment since beta check is a network call.
In compare to that "let" also introduces a temporal dead zone within the block execution. So I think we should be ok with null in staging during environment initialization period.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we are not using await in our codebase.

When is this being called @smrutiparida? This is called just once and before being resolved it is null, right? In that case we will use the default which is production?

What if this is in dev, that is not influenced and we will use whatever is in the .env right?

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.

@mountiny

When is this being called @smrutiparida? This is called just once and before being resolved it is null, right? In that case we will use the default which is production?

Yes, we will fall back to production API_URL

What if this is in dev, that is not influenced and we will use whatever is in the .env right?

Yes.
One note here is that presently .env do not have STAGING_EXPENSIFY_URL and STAGING_SECURE_EXPENSIFY_URL configuration. The present values are hard-coded in Config.js. We need to init the values in .env in order to use them in dev environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, we will fall back to production API_URL

This will have to reset everytime the app is killed and opened again, right? If I just put it in a background and come back the value will be still "cached"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@parasharrajat can you elaborate more, I think we trying to avoid adding middlewares so there would have to be strong reason for this.

@parasharrajat parasharrajat Nov 16, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking that we create a Middleware that switches the URL based on the ENV. But that seems not possible. Our Middlewares apply after the request is sent to the server.

@smrutiparida Could you please share some suggestions on what are the options?

Yes, we will fall back to production API_URL

How? the local environment variable is initialized with null value. Until the promise is resolved it will be null.

Thus, if shouldUseStagingServer is set, requests will go to staging even if a user is using the PROD app. This sounds wrong. Right?

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.

How? the local environment variable is initialized with null value. Until the promise is resolved it will be null.
Thus, if shouldUseStagingServer is set, requests will go to staging even if a user is using the PROD app. This sounds wrong. Right?

No, with below logic user can only be in staging with envrionment set to staging.
if (environment === CONST.ENVIRONMENT.STAGING && shouldUseStagingServer) {.... }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh Correct. I don't know why I got confused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldUseStagingServer should never be set to truthy value in prod app, the toggle does not exist in there I believe.

@mountiny

Copy link
Copy Markdown
Contributor

@parasharrajat @smrutiparida So how are we feeling on this one? I think we should decide here. If you think we should not merge this, can you please post a summary of the reasons why not to do so. For now it just feels the only problem would be that for short period of time in staging app we would point to production, but given that should be short time at app start it does not feel like a blocker if other solutions involve changing our entire deployment pipeline.

@parasharrajat

Copy link
Copy Markdown
Member

I am not sure too. If we are fine with a short delay, its fine to merge it. I will test it to determine if this can be a real problem.

There are two issues

  1. First, due to the delay the correct staging server will not be called.
  2. Second, it will impact the bootup time for the app. Can't tell if it has a big impact.

Explanation of 2: Because we are making an API request in the global scope, it will be called as soon as the app is bootup. Js is single-threaded, thus even though HTTP calls are async, it will have some impact.

@mountiny

mountiny commented Nov 17, 2022

Copy link
Copy Markdown
Contributor

it will have some impact.

But since we dont wait for the response this impact should be really small right.

First, due to the delay the correct staging server will not be called.

I think in general we should not be in state where calling prod api from staging app should be a problem. This should work just fine in 99.9% cases.

Is there potentially any other way to handle this without the promise. For example how is the badge added to the app (DEV, Staging), that is also coming from same Promise I assume.

I think we could move this promise after app is loaded, the staging app should work just fine with production API so if we would switch this after the app boots up, I dont think it would be too harmful.

But again, is there no better solution? @smrutiparida you spent lots of time looking into this, any ideas? We dont necesarily need to follow what was in the proposal.

@parasharrajat

parasharrajat commented Nov 17, 2022

Copy link
Copy Markdown
Member

Is there potentially any other way to handle this without the promise. For example how is the badge added to the app (DEV, Staging), that is also coming from the same Promise I assume

Yes, but they are hooked to the component lifecycle. Components are started after the app is bootup.

But since we don't wait for the response this impact should be really small right?

Yes, but it is adding up to the existing code execution. We don't have to be too much concerned about it. It won't have much impact.

Mainly, if we have a better solution let's do that.

@mountiny

Copy link
Copy Markdown
Contributor

Mainly, we have a betters solution let's do that.

I am up for better solutions, how could we do that?

@parasharrajat

Copy link
Copy Markdown
Member

Sorry, I wanted to say if we have one. Mistype 😄

@mountiny

Copy link
Copy Markdown
Contributor

😂 got it

@mountiny

Copy link
Copy Markdown
Contributor

I think this solution is fine for now. What I would change is try to move the promise to get the environment somewhere later in the app lifecycle so it does not slow down the boot time.

@smrutiparida can you think of a way to achieve that.

@smrutiparida

Copy link
Copy Markdown
Contributor Author

What I would change is try to move the promise to get the environment somewhere later in the app lifecycle so it does not slow down the boot time.

  1. This is an interesting topic. We may have to care about all such Promises and see what speed can be achieved if they are moved to a queue and executed after app boot time.This is a large architecture effort.
  2. Beyond saving app boot time, delaying environment init shall make app to use prod url in staging. Rather we should think how the Promise can be executed sooner, so that environment is never found null.

@mountiny

Copy link
Copy Markdown
Contributor

I feel like this is tricky, we should avoid adding something which will be blocking the boot time.

I think that now when we have a better idea of the context and potential drawbacks, we should bring this up to Slack for discussion with more engineers. Unfortunately, I will be mostly ooo tomorrow.

The issue I see here is that while this solves the issue it is at cost of a promise which is executed also on production App which is unnecessary load in that case and we focus on performance mainly right now.

Would anyone be able to summarize this context and post in Slack open-source please? cc @smrutiparida?

@mountiny

Copy link
Copy Markdown
Contributor

I will close this in favour of this PR #12880

In Slack we agreed that we do not want any promises especially if they call play store at the app start.

You both will be compensated of course 🙇

@mountiny mountiny closed this Nov 21, 2022
@parasharrajat

Copy link
Copy Markdown
Member

Happy to review the other PR.

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.

3 participants