cloudflare / workers-sdk

โ›…๏ธ Home to Wrangler, the CLI for Cloudflare Workersยฎ
https://developers.cloudflare.com/workers/
Apache License 2.0
2.7k stars 709 forks source link

๐Ÿ› BUG: `UND_ERR_SOCKET` when trying `wrangler dev` with `http_proxy` env variable being set #3674

Open davuses opened 1 year ago

davuses commented 1 year ago

Which Cloudflare product(s) does this pertain to?

Workers Runtime, Wrangler core

What version(s) of the tool(s) are you using?

wrangler 3.3.0

What version of Node are you using?

v18.15.0

What operating system are you using?

WSL

Describe the Bug

When I try to run wrangler dev under WSL with env variables http_proxy being set, error UND_ERR_SOCKET occurs. After I remove the env variable: http_proxy="", the error doesn't occur.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

โ–ฒ [WARNING] Failed to get worker definitions TypeError: fetch failed

      at fetch (/home/sakana/bold-block-8f14/node_modules/wrangler/wrangler-dist/cli.js:16584:17)
      at async getRegisteredWorkers
  (/home/sakana/bold-block-8f14/node_modules/wrangler/wrangler-dist/cli.js:126328:22)
      at async getBoundRegisteredWorkers
  (/home/sakana/bold-block-8f14/node_modules/wrangler/wrangler-dist/cli.js:126347:29) {
    cause: SocketError: other side closed
        at Socket.onSocketEnd
  (/home/sakana/bold-block-8f14/node_modules/wrangler/wrangler-dist/cli.js:8477:27)
        at Socket.emit (node:events:525:35)
        at endReadableNT (node:internal/streams/readable:1359:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
      code: 'UND_ERR_SOCKET',
      socket: {
        localAddress: '172.23.52.152',
        localPort: 53932,
        remoteAddress: '192.168.1.7',
        remotePort: 10802,
        remoteFamily: 'IPv4',
        timeout: undefined,
        bytesWritten: 257,
        bytesRead: 39
      }
    }
  }
uniform641 commented 1 year ago

I got the same problem.

โ•ฐโ”€ npm run dev

> dev
> wrangler dev src/index.ts

Proxy environment variables detected. We'll use your proxy for fetch requests.
 โ›…๏ธ wrangler 3.13.1
-------------------
Your worker has access to the following bindings:
- D1 Databases:
  - DB: test (************************)
โŽ” Starting local server...
[mf:inf] Ready on http://0.0.0.0:8787
[mf:inf] - http://127.0.0.1:8787
โŽ” Shutting down local server...
โœ˜ [ERROR] Failed to unregister worker TypeError: fetch failed

      at fetch
  (/home/uniform64/Documents/code/test-hono/node_modules/wrangler/wrangler-dist/cli.js:16838:17)
      at async unregisterWorker
  (/home/uniform64/Documents/code/test-hono/node_modules/wrangler/wrangler-dist/cli.js:126908:5)
      at async Promise.allSettled (index 0) {
    cause: SocketError: other side closed
        at Socket.onSocketEnd
  (/home/uniform64/Documents/code/test-hono/node_modules/wrangler/wrangler-dist/cli.js:8506:27)
        at Socket.emit (node:events:525:35)
        at endReadableNT (node:internal/streams/readable:1359:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
  {
      code: 'UND_ERR_SOCKET',
      socket: {
        localAddress: '127.0.0.1',
        localPort: 51958,
        remoteAddress: '127.0.0.1',
        remotePort: 7890,
        remoteFamily: 'IPv4',
        timeout: undefined,
        bytesWritten: 5103,
        bytesRead: 10126
      }
    }
  }

โฌฃ Listening at http://0.0.0.0:8787
- http://127.0.0.1:8787
Total Upload: 46.78 KiB / gzip: 11.51 KiB
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ [b open a browser[d] open Devtools[l turn on local mode[c clear console[x] to exit โ”‚
โ”‚                                                                                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
reekystive commented 6 months ago

Exactly the same error as @uniform641.

Steps to reproduce

  1. Create a fresh wrangler project
  2. Run pnpm install
  3. Set http_proxy and https_proxy environment variables
  4. Run wrangler dev
  5. Error when turning off local mode with l key

Logs

$ pnpm dev

> dawn-disk-c7f8@0.0.0 dev .../dawn-disk-c7f8
> wrangler dev

Proxy environment variables detected. We'll use your proxy for fetch requests.
 โ›…๏ธ wrangler 3.51.2
-------------------
โŽ” Starting local server...
[wrangler:inf] Ready on http://localhost:8787
โŽ” Shutting down local server...
โœ˜ [ERROR] Failed to unregister worker TypeError: fetch failed

      at fetch
  (.../dawn-disk-c7f8/node_modules/.pnpm/wrangler@3.51.2_@cloudflare+workers-types@4.20240419.0/node_modules/wrangler/wrangler-dist/cli.js:17033:19)
      at async unregisterWorker
  (.../dawn-disk-c7f8/node_modules/.pnpm/wrangler@3.51.2_@cloudflare+workers-types@4.20240419.0/node_modules/wrangler/wrangler-dist/cli.js:127770:5)
      at async Promise.allSettled (index 0) {
    cause: SocketError: other side closed
        at Socket.onSocketEnd
  (.../dawn-disk-c7f8/node_modules/.pnpm/wrangler@3.51.2_@cloudflare+workers-types@4.20240419.0/node_modules/wrangler/wrangler-dist/cli.js:7263:27)
        at Socket.emit (node:events:529:35)
        at Socket.emit (node:domain:489:12)
        at endReadableNT (node:internal/streams/readable:1400:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
      code: 'UND_ERR_SOCKET',
      socket: {
        localAddress: '127.0.0.1',
        localPort: 53033,
        remoteAddress: '127.0.0.1',
        remotePort: 8898,
        remoteFamily: 'IPv4',
        timeout: undefined,
        bytesWritten: 1265,
        bytesRead: 1677
      }
    }
  }

Total Upload: 5.45 KiB / gzip: 1.76 KiB
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ [b open a browser, [d] open Devtools, [l] turn on local mode,[c] clear console, [x] to exit  โ”‚
โ”‚                                                                                              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ