Skip to content
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

[Vite] [Cloudflare] dev server start failed with http_proxy environment variable #9233

Open
bojieyang opened this issue Apr 15, 2024 · 0 comments

Comments

@bojieyang
Copy link

Reproduction

1.the http_proxy in my env variables and it's work fine with other tools like curl and wget

env | grep http_proxy

http_proxy=http://192.168.2.1:7890

  1. Use vite and cloudflare template to create a remix project
    npx create-remix@latest --template remix-run/remix/templates/cloudflare

  2. Run the Vite dev server:

npm run dev

then failed with information below:

> dev
> remix vite:dev

Proxy environment variables detected. We'll use your proxy for fetch requests.
TypeError: fetch failed
    at fetch (/.../node_modules/wrangler/wrangler-dist/cli.js:17033:19)
    at async getRegisteredWorkers (/..../node_modules/wrangler/wrangler-dist/cli.js:127783:22)
    at async getBoundRegisteredWorkers (/.../node_modules/wrangler/wrangler-dist/cli.js:127803:29)
    at async getMiniflareOptionsFromConfig (/.../node_modules/wrangler/wrangler-dist/cli.js:173568:29)
    at async getPlatformProxy (/.../node_modules/wrangler/wrangler-dist/cli.js:173540:28)
    at async configureServer (/.../node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:55:11)
    at async _createServer (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:64978:24)
    at async configResolved (/../node_modules/@remix-run/dev/dist/vite/plugin.js:746:27)
    at async Promise.all (index 2)
    at async resolveConfig (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:68410:5) {
  cause: SocketError: other side closed
      at Socket.onSocketEnd (/.../node_modules/wrangler/wrangler-dist/cli.js:7263:27)
      at Socket.emit (node:events:526:35)
      at Socket.emit (node:domain:488:12)
      at endReadableNT (node:internal/streams/readable:1589:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '192.168.2.215',
      localPort: 54946,
      remoteAddress: '192.168.2.1',
      remotePort: 7890,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 256,
      bytesRead: 39
    }
  }
}
  1. if I run Wrangler with:

npm run build

then failed with information below:

> build
> remix vite:build

Proxy environment variables detected. We'll use your proxy for fetch requests.
TypeError: fetch failed
    at fetch (/.../node_modules/wrangler/wrangler-dist/cli.js:17033:19)
    at async getRegisteredWorkers (/.../node_modules/wrangler/wrangler-dist/cli.js:127783:22)
    at async getBoundRegisteredWorkers (/.../node_modules/wrangler/wrangler-dist/cli.js:127803:29)
    at async getMiniflareOptionsFromConfig (/.../node_modules/wrangler/wrangler-dist/cli.js:173568:29)
    at async getPlatformProxy (/.../node_modules/wrangler/wrangler-dist/cli.js:173540:28)
    at async configureServer (/.../node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:55:11)
    at async _createServer (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:64978:24)
    at async configResolved (/.../node_modules/@remix-run/dev/dist/vite/plugin.js:746:27)
    at async Promise.all (index 2)
    at async Module.resolveConfig (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:68410:5) {
  cause: SocketError: other side closed
      at Socket.onSocketEnd (/.../node_modules/wrangler/wrangler-dist/cli.js:7263:27)
      at Socket.emit (node:events:526:35)
      at Socket.emit (node:domain:488:12)
      at endReadableNT (node:internal/streams/readable:1589:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '192.168.2.215',
      localPort: 55852,
      remoteAddress: '192.168.2.1',
      remotePort: 7890,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 256,
      bytesRead: 39
    }
  }
}

If I remove the http_proxy env setting. then everything is OK.
I find the doc on Cloudflare and it seems wrangler support http_proxy env.

System Info

System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1
    Memory: 177.72 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
  Browsers:
    Chrome: 123.0.6312.123
    Safari: 17.4.1
  npmPackages:
    @remix-run/cloudflare: ^2.8.1 => 2.8.1 
    @remix-run/cloudflare-pages: ^2.8.1 => 2.8.1 
    @remix-run/dev: ^2.8.1 => 2.8.1 
    @remix-run/react: ^2.8.1 => 2.8.1 
    vite: ^5.1.0 => 5.2.8

Used Package Manager

npm

Expected Behavior

npm run dev command start the dev server successfully.
npm run build command build successfully.

Actual Behavior

Run the Vite dev server:

npm run dev

then failed with information below:

> dev
> remix vite:dev

Proxy environment variables detected. We'll use your proxy for fetch requests.
TypeError: fetch failed
    at fetch (/.../node_modules/wrangler/wrangler-dist/cli.js:17033:19)
    at async getRegisteredWorkers (/..../node_modules/wrangler/wrangler-dist/cli.js:127783:22)
    at async getBoundRegisteredWorkers (/.../node_modules/wrangler/wrangler-dist/cli.js:127803:29)
    at async getMiniflareOptionsFromConfig (/.../node_modules/wrangler/wrangler-dist/cli.js:173568:29)
    at async getPlatformProxy (/.../node_modules/wrangler/wrangler-dist/cli.js:173540:28)
    at async configureServer (/.../node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:55:11)
    at async _createServer (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:64978:24)
    at async configResolved (/../node_modules/@remix-run/dev/dist/vite/plugin.js:746:27)
    at async Promise.all (index 2)
    at async resolveConfig (file:///.../node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:68410:5) {
  cause: SocketError: other side closed
      at Socket.onSocketEnd (/.../node_modules/wrangler/wrangler-dist/cli.js:7263:27)
      at Socket.emit (node:events:526:35)
      at Socket.emit (node:domain:488:12)
      at endReadableNT (node:internal/streams/readable:1589:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '192.168.2.215',
      localPort: 54946,
      remoteAddress: '192.168.2.1',
      remotePort: 7890,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 256,
      bytesRead: 39
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants