Replace ProxyAgent with EnvHttpProxyAgent in cli #251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have an issue with using Convex local deployments with "Claude code on the web", that I think I solved🤞
My issue is that the Convex CLI would hang when running
npx convex dev --onceon "Claude code on the web". This is an issue because it makes using Convex with agentic background agents unusable (Claude code on the web in this case).What I want is to setup a local isolated Convex deployment for Claude that would have all the same features as a normal cloud deployment, but mainly the codegen.
I did some debugging with the help from Claude and found out the Convex CLI does not respect the
NO_PROXYenvironment variable that is set in "Claude code on the web" environment. From this we suspected that Convex would incorrectly try to proxy localhost.Our quick fix was to use the pnpm patch feature and patch
npm-packages/convex/src/cli/index.tsto useEnvHttpProxyClientbecause this class would automatically setup the proxy agent based on the environment variables available (undici docs). This seemingly fixed the issue.To reproduce the issue, I forked the convex-tutorial repo and asked "Claude code on the web":
and it hanged at the second step "waiting for local backend to start...".
Lastly to verify that I had a fix, I patched
ProxyAgenttoEnvHttpProxyAgent(exact PR here) and asked "Claude code on the web", in the same thread:Claude responded with:
Proving to me that this solved the issue!
Everything works as I would expect with this and I'm currently using a patched version of convex in my project. Would be awesome if this was a suitable contribution for the team! Love the product btw 🫶
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.