fix: fix install context is not right#613
Conversation
Summary of ChangesHello @fatelei, 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 an issue where plugin installations could be prematurely terminated due to the cancellation of the associated HTTP request. By implementing a standalone, time-limited context for each asynchronous installation task, the changes guarantee that plugin installations proceed to completion regardless of the client's connection status, thereby enhancing the reliability of the installation process. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug where plugin installation tasks could be prematurely cancelled. By creating a detached context for each background installation task, you ensure they can complete independently of the initial HTTP request. The implementation is solid. I have one minor suggestion to improve maintainability by making the hardcoded timeout value configurable.
| for _, job := range jobs { | ||
| jobCopy := job | ||
| // create a detached context for async task to avoid http request cancellation | ||
| taskCtx, taskCancel := context.WithTimeout(context.Background(), 15*time.Minute) |
There was a problem hiding this comment.
For better maintainability and flexibility, it's recommended to avoid hardcoding timeout values. Consider making the 15-minute timeout configurable by adding a new field to app.Config (e.g., PluginInstallTimeout) and using that value here. This would allow operators to adjust the timeout based on their specific needs and environment.
| taskCtx, taskCancel := context.WithTimeout(context.Background(), 15*time.Minute) | |
| taskCtx, taskCancel := context.WithTimeout(context.Background(), config.PluginInstallTimeout) |
There was a problem hiding this comment.
I think gemini is right. This behavior should be configurable.
| for _, job := range jobs { | ||
| jobCopy := job | ||
| // create a detached context for async task to avoid http request cancellation | ||
| taskCtx, taskCancel := context.WithTimeout(context.Background(), 15*time.Minute) |
There was a problem hiding this comment.
I think gemini is right. This behavior should be configurable.
Description
fix #612
install package should use standalone context
Type of Change
Essential Checklist
Testing
Bug Fix (if applicable)
Fixes #123orCloses #123)Additional Information
Please provide any additional context that would help reviewers understand the changes.