Skip to content

fixing issue 6989#10253

Merged
shettyvarun268 merged 7 commits intomainfrom
fix/issue-6989
Apr 6, 2026
Merged

fixing issue 6989#10253
shettyvarun268 merged 7 commits intomainfrom
fix/issue-6989

Conversation

@shettyvarun268
Copy link
Copy Markdown
Contributor

@shettyvarun268 shettyvarun268 commented Apr 2, 2026

Fixes: #6989

Deployments can falsely exit with success code 0 even when internal tasks fail. Right before shutting down, the CLI tries to send background analytics. In secure or restrictive CI/CD environments, this analytics ping hangs and times out. That timeout crashes the CLI wrapper's error-handler prematurely, masking the original deployment failure before it can set the non-zero exit code.

Solution: We wrapped the background analytics timeouts in protective try...catch blocks. Now, if the telemetry tracker hangs or fails to reach the portals, the CLI simply ignores the analytics failure and continues with its shutdown routine. This ensures the CLI always returns the authentic deployment failure code to the host system.

Did not add new unit tests for this specific logic because the wrapper lives at the top-level process exit boundary. Writing automated tests here requires faking CLI process shutdowns and restricted networks, which creates brittle mocks. Verified the logic safety using an isolated sandbox playground and confirmed all existing test trees continue to pass.

@shettyvarun268
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces error handling for analytics tracking in src/command.ts to ensure that failures in tracking do not cause commands to exit with an error. While the changes improve robustness, the review feedback points out that a trackGA4 call remains outside the try block in the success path, which could still trigger an unintended error exit if it fails. Additionally, the reviewer suggests refactoring the logic to reduce nesting and duplication, adhering to the repository's style guide.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the robustness of analytics tracking in src/command.ts by wrapping tracking logic in try/catch blocks and logging failures with logger.debug. This ensures that analytics errors do not crash the CLI. A review comment suggests refactoring the success path to reduce nesting, consistent with the repository's style guide.

@shettyvarun268
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces error handling for analytics tracking in src/command.ts by wrapping tracking calls in try-catch blocks and logging failures as debug messages. This prevents analytics failures from interfering with the command execution flow. The success path was also refactored to use an array-based approach for managing multiple tracking promises. Feedback suggests applying the same refactoring to the error path for consistency and better readability, replacing the current ternary operator and Promise.resolve() logic.

@shettyvarun268
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces error handling for analytics tracking in both the success and error paths of command execution. The changes wrap tracking logic in try-catch blocks to prevent tracking failures from interrupting the main process. Review feedback suggests refactoring these blocks to use promise-based .catch() methods to reduce nesting, adhering to the repository's style guide, and recommends using optional chaining for safer access to properties on the error object.

@shettyvarun268 shettyvarun268 marked this pull request as ready for review April 3, 2026 00:30
Copy link
Copy Markdown
Member

@joehan joehan left a comment

Choose a reason for hiding this comment

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

LGTM, but please add a CHANGELOG entry saying something like:

- Fixed an issue where functions deployments would silently fail (#6989)

src/command.ts Outdated
);
);
}
await withTimeout(5000, Promise.all(tracks));
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.

Nit: 5s is insanely long to wait for these calls, probably safe to lower this to 1s - same for the other one.

@shettyvarun268 shettyvarun268 merged commit bca274a into main Apr 6, 2026
47 checks passed
@shettyvarun268 shettyvarun268 deleted the fix/issue-6989 branch April 6, 2026 19:32
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.

firebase deploy returns an exit code == 0 even if a function failed to be deployed

3 participants