Conversation
There was a problem hiding this comment.
Code Review
This pull request improves stream error response handling in Gaxios by ensuring chunks are joined correctly without comma corruption, and adds a corresponding test. It also clears proxy environment variables before MTLS tests. The reviewer pointed out that modifying these environment variables without restoring them could cause test pollution, and suggested backing up and restoring them in an afterEach block.
| beforeEach(() => { | ||
| setEnv({ | ||
| HTTP_PROXY: undefined, | ||
| HTTPS_PROXY: undefined, | ||
| http_proxy: undefined, | ||
| https_proxy: undefined, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Modifying global environment variables in beforeEach without restoring them can lead to test pollution and flaky tests in other parts of the test suite. It is highly recommended to back up the original environment variables and restore them in an afterEach block.
| beforeEach(() => { | |
| setEnv({ | |
| HTTP_PROXY: undefined, | |
| HTTPS_PROXY: undefined, | |
| http_proxy: undefined, | |
| https_proxy: undefined, | |
| }); | |
| }); | |
| let originalEnv: Record<string, string | undefined>; | |
| beforeEach(() => { | |
| originalEnv = { | |
| HTTP_PROXY: process.env.HTTP_PROXY, | |
| HTTPS_PROXY: process.env.HTTPS_PROXY, | |
| http_proxy: process.env.http_proxy, | |
| https_proxy: process.env.https_proxy, | |
| }; | |
| setEnv({ | |
| HTTP_PROXY: undefined, | |
| HTTPS_PROXY: undefined, | |
| http_proxy: undefined, | |
| https_proxy: undefined, | |
| }); | |
| }); | |
| afterEach(() => { | |
| setEnv(originalEnv); | |
| }); |
With this fix, we are hoping to address google-gemini/gemini-cli#21884 and #8768.
Credit to @jerrylin3321 for originally creating this branch. We are creating a PR to add a few additional changes on top of it.