-
Notifications
You must be signed in to change notification settings - Fork 993
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
Fix GraphQL proxy in dev environments without IPv6 #8233
Fix GraphQL proxy in dev environments without IPv6 #8233
Conversation
Hi @chousheng Welcome to Redwood! For a first PR, you definitely took on a challenge. Well done. And huge thank you for the amount of QA testing — very helpful. This PR only includes code changes for Webpack and GitPod. It's likely you didn't add additional files/commits or didn't push them to GitHub. Could you please double-check? @jtoar we'll need to sync up and spend some time on this one. |
Thank you @thedavidprice for the reminder! I just double-checked the files. That's all I changed. Actually, the major code change was a one-liner in the webpack config packages/core/config/webpack.development.js. |
@chousheng and @thedavidprice I recall this setting be changed once or twice before from localhost to :: etc. see #3434 I’m not sure my at this change without maybe some logic or detection is sufficient. |
Hi @dthyresson, thanks for the comment. I looked at PR #3434 as well. PR #3434, like this PR, ended up changing the default setting in Gitpod from Besides, we are currently using |
Related: #8019 |
@Tobbe talking with @thedavidprice, if you feel like you understand the setup enough to make decisions could you take lead on this and also get in your Fastify PR? If not I'm happy to pair |
Thanks for your PR @chousheng! Great work 🙂 |
@Tobbe, thank you! |
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
…te-default * 'main' of github.com:redwoodjs/redwood: (23 commits) fix: remove react 17/18 warning (redwoodjs#8300) chore(release): tolerate lerna publish faliure Recover lost connection (redwoodjs#8284) chore(deps): update dependency @faker-js/faker to v8 (redwoodjs#8296) chore(release): better git commits during release feat: experimental - Studio Overview and Performance Widgets (redwoodjs#8292) fix(forms): disable webpack-dev-server overlay (redwoodjs#8298) Fix studio lint warning (redwoodjs#8297) Fastify server: Default to localhost (redwoodjs#8019) Fix GraphQL proxy in dev environments without IPv6 (redwoodjs#8233) fix(deps): update dependency @graphiql/plugin-explorer to v0.1.18 (redwoodjs#8290) chore(deps): update dependency supertokens-auth-react to v0.32.3 (redwoodjs#8289) Add `setup sentry` command (redwoodjs#7790) chore: readme update core team and all contributors (redwoodjs#8288) fix(deps): update nivo monorepo to ^0.83.0 (redwoodjs#8286) fix(deps): update dependency babel-plugin-polyfill-corejs3 to v0.8.1 (redwoodjs#8281) chore(deps): update dependency @replayio/playwright to v0.3.30 (redwoodjs#8282) fix(deps): update dependency webpack to v5.82.1 (redwoodjs#8283) Add epilogue to builders (redwoodjs#8285) feat(studio): v2 studio (redwoodjs#8173) ...
This PR fixes the problem that the GraphQL dev proxy fails (EADDRNOTAVAIL) when the IPv6 loopback interface is unavailable.
Why
I was following the tutorial (in Chapter 2 - Getting Dynamic) but got the proxy error below when accessing the scaffolded
/posts
route:So I dived into it and found the problem was that the dev proxy tried to connect to the GraphQL server via IPv6
::1
(see code here) and my dev environment did not have the IPv6 loopback interface enabled:However, I could not enable IPv6 because I was using a VS Code Dev Container with Docker Desktop on macOS, where IPv6 had not been supported yet (see docker/for-mac#1432).
Here are some related problem reports:
Changes
Looking at the history, I found that PR #940 fixed an intermittent connection failure problem (ECONNRESET) but introduced this new problem (EADDRNOTAVAIL).
PR #940 had two changes:
Connection: keep-live
to the HTTP request header sending to the GraphQL server behind the proxylocalhost
(auto IPv4 or IPv6) to::1
(IPv6 only).Searching around, I believe the first change alone fixed the ECONNRESET problem, as reported here and here. That is, to avoid the new EADDRNOTAVAIL problem, we can safely revert the second change to use
localhost
(which can automatically resolve to either IPv4 or IPv6 loopback address depending on the environment). So, I revert the second change in this PR.Besides, as a side effect, we no longer need to set RWJS_DEV_API_URL env var in Gitpod anymore. So, I remove the RWJS_DEV_API_URL settings in the GitPod config in this PR.
Testing
I have manually tested this PR using the rw-test-app (created by running
yarn run build:test-project
) in the environments below:I would like to let CI test the rest.
Thanks the core team for making a welcoming community. This is my first PR to Redwood (also the first PR to the open-source world). I would appreciate any feedback!