-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[FDC] Fix firebase dataconnect:sdk:generate --watch
#9055
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @fredzqm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request resolves a critical logging issue with the firebase dataconnect:sdk:generate --watch command, ensuring that all output from the SDK generation process is properly displayed. It also refactors the underlying SDK generation mechanism to be more efficient and aligned with the Data Connect toolkit's design, improving the overall developer experience when generating client SDKs.
Highlights
- Fix
dataconnect:sdk:generate --watchlogging: Addresses a bug where thefirebase dataconnect:sdk:generate --watchcommand would "swallow" or suppress logs from the underlying SDK generation process, making it difficult to see real-time output. - Improved SDK generation process: The SDK generation logic has been refactored to call the underlying Data Connect toolkit once per service that has declared SDKs, rather than iterating and calling it per connector. This streamlines the process and aligns with the toolkit's expected behavior.
- Enhanced log streaming: The internal
DataConnectEmulator.generatemethod now useschildProcess.spawnwithstdio: "inherit". This change ensures that output from the external SDK generation tool is directly streamed to the console, resolving the log suppression issue. - Simplified
generatearguments: TheconnectorIdargument has been removed from theDataConnectGenerateArgsinterface and subsequent calls, as the SDK generation process is now handled at the service level rather than per individual connector.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this 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 correctly fixes an issue where logs were being swallowed by the firebase dataconnect:sdk:generate --watch command. The change from a synchronous spawnSync to an asynchronous spawn with inherited stdio is the right approach. The related API changes are consistent and well-implemented. I have one suggestion to improve the clarity and consistency of the new asynchronous error handling.
|
[not urgent] While swapping Please take a look~ Not in a rush |
| // Handle errors like command not found | ||
| reject(err); | ||
| }); | ||
| } catch (e: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure errors like missing Rosetta will be caught by this block, not the proc.on("error") above? I doubt spawn throws synchronously (as opposed to spawnSync).
Consider rejecting all errors in the Promise constructor and chaining .catch(...) to handle errors there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is copied from _runBinary here
To answer your question, honestly I am not sure. I don't know how to re-produce the original error.
We should probably extract a helper to run long-running emulator-ish binary process.
Can we do that separately? This bug here is pretty bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay fair enough. Feel free to split that into a follow-up
| // Handle errors like command not found | ||
| reject(err); | ||
| }); | ||
| } catch (e: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay fair enough. Feel free to split that into a follow-up
While switching
fdc generatetofdc sdk generatecmd, I found this bug.fdc sdk generate --watchwould hang with no output and wait for any file changes.The previous behavior hangs because the cmd never exits.
This PR changed it to pipe stdout, so developers can see what it's doing behind the scenes.