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

fix: slow startup if no network is available #5055

Merged
merged 5 commits into from
Jan 31, 2023

Conversation

stfsy
Copy link
Contributor

@stfsy stfsy commented Oct 1, 2022

Preventing slow startups (> 60s) if no network is available. Tried to pick a reasonable timeout. Currently from Barcelona the NPM commands take 500ms to return.

Description

Fixes #5054

Scenarios Tested

Sample Commands

@stfsy stfsy changed the title fix: add timeouts to npm commands fix: slow startup if no network is available Oct 1, 2022
@@ -45,6 +46,7 @@ export function getFunctionsSDKVersion(sourceDir: string): string | void {
const child = spawn.sync("npm", ["list", "firebase-functions", "--json=true"], {
cwd: sourceDir,
encoding: "utf8",
timeout: NPM_COMMAND_TIMEOUT_MILLIES,
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually removed this spawn in a recent commit, do you mind pulling in the changes from master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colerogers thank you very much, rebased from master

To prevent slow startups if no network is available
@@ -16,6 +16,7 @@ interface NpmShowResult {
}

const MIN_SDK_VERSION = "2.0.0";
const NPM_COMMAND_TIMEOUT_MILLIES = 3000;
Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed this internally and think that 10000 would be a more appropriate timeout for customers with slower connectivity or an intermittent issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colerogers ok good point. I updated the value as per your recommendation

Copy link
Contributor

@colerogers colerogers left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@colerogers colerogers enabled auto-merge (squash) December 16, 2022 17:44
@stfsy
Copy link
Contributor Author

stfsy commented Jan 24, 2023

@colerogers anything I need to? any more prerequisites for it getting merged? ☺

@codecov-commenter
Copy link

Codecov Report

Base: 56.23% // Head: 56.24% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (3a47562) compared to base (4408aeb).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 3a47562 differs from pull request most recent head 7e8c90c. Consider uploading reports for the commit 7e8c90c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5055      +/-   ##
==========================================
+ Coverage   56.23%   56.24%   +0.01%     
==========================================
  Files         317      317              
  Lines       21409    21410       +1     
  Branches     4366     4366              
==========================================
+ Hits        12040    12043       +3     
+ Misses       8319     8318       -1     
+ Partials     1050     1049       -1     
Impacted Files Coverage Δ
src/deploy/functions/runtimes/node/versioning.ts 44.64% <100.00%> (+1.00%) ⬆️
src/emulator/auth/state.ts 85.43% <0.00%> (+0.56%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@colerogers colerogers merged commit 06ec3c1 into firebase:master Jan 31, 2023
@stfsy
Copy link
Contributor Author

stfsy commented Feb 4, 2023

@colerogers Thanks for merging!

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.

Painfully slow emulator start if no network is available
4 participants