-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: improve environment variable handling and CORS configuration fo… #803
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
base: main
Are you sure you want to change the base?
Conversation
…r Vercel deployment
Summary of ChangesHello @inoribea, 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 significantly improves the application's resilience and deployment flexibility by refining environment variable handling and addressing critical CORS-related issues. It introduces intelligent mechanisms for WebSocket URL determination and conditional skipping of provider health checks, ensuring smoother operation across different deployment environments, especially Vercel. Additionally, it standardizes code quality through a new ESLint configuration. Highlights
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.
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 several well-implemented improvements for environment-specific configurations, particularly for Vercel deployments. Key changes include dynamic WebSocket URL detection to prevent connection errors in production browser environments, a mechanism to skip provider health checks to mitigate CORS issues, and updates to font configurations to resolve loading problems. A new ESLint configuration is also added to enforce code style. My feedback focuses on minor code simplifications and ensuring consistency with the newly introduced linting rules. Overall, the changes are solid and effectively address the stated objectives.
|
|
||
| private _connect(): Promise<void> { | ||
| // If URL is empty, WebSocket is disabled - silently skip connection | ||
| if (!this.opts.url || this.opts.url === '') { |
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.
For conciseness, you can simplify this check. In TypeScript/JavaScript, an empty string ('') is a falsy value, so !this.opts.url will correctly evaluate to true for null, undefined, and ''. This makes the explicit check for an empty string redundant.
| if (!this.opts.url || this.opts.url === '') { | |
| if (!this.opts.url) { |
|
|
||
| this.opts.onError?.(event) | ||
| // Only log error if not intentionally disabled | ||
| if (this.opts.url && this.opts.url !== '') { |
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.
| } | ||
| if (this.opts.autoReconnect && !this.shouldClose) { | ||
| // Don't auto-reconnect if WebSocket is disabled | ||
| if (this.opts.autoReconnect && !this.shouldClose && this.opts.url && this.opts.url !== '') { |
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 condition can also be simplified. The check for this.opts.url && this.opts.url !== '' is redundant. A simple truthy check with this.opts.url is sufficient to cover cases where the URL is undefined, null, or an empty string.
| if (this.opts.autoReconnect && !this.shouldClose && this.opts.url && this.opts.url !== '') { | |
| if (this.opts.autoReconnect && !this.shouldClose && this.opts.url) { |
| const skipHealthChecks = envSkipHealthCheck !== undefined | ||
| ? envSkipHealthCheck === 'true' || envSkipHealthCheck === true | ||
| : defaultSkipInBrowser |
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 for determining skipHealthChecks can be made more concise. Using String(envSkipHealthCheck) === 'true' handles both boolean true and string 'true' values correctly, while still falling back to defaultSkipInBrowser when envSkipHealthCheck is undefined.
| const skipHealthChecks = envSkipHealthCheck !== undefined | |
| ? envSkipHealthCheck === 'true' || envSkipHealthCheck === true | |
| : defaultSkipInBrowser | |
| const skipHealthChecks = envSkipHealthCheck !== undefined | |
| ? String(envSkipHealthCheck) === 'true' | |
| : defaultSkipInBrowser |
|
|
||
| if (skipHealthChecks) { | ||
| // eslint-disable-next-line no-console | ||
| console.log('[Provider] Skipping health checks (SKIP_PROVIDER_HEALTH_CHECK=true or browser environment)') |
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.
The new ESLint configuration in eslint.config.ts disallows console.log. To adhere to the new linting rules, please use console.info instead, which is permitted.
| console.log('[Provider] Skipping health checks (SKIP_PROVIDER_HEALTH_CHECK=true or browser environment)') | |
| console.info('[Provider] Skipping health checks (SKIP_PROVIDER_HEALTH_CHECK=true or browser environment)') |
Summary
This PR improves environment variable handling and CORS configuration for Vercel deployment, fixing issues with provider health checks and WebSocket connections.
Details
Testing