workers-sdk: ๐Ÿ› BUG: wrangler dev -> fetch failed

Which Cloudflare product(s) does this pertain to?

Workers/Other, Wrangler

What version of Wrangler are you using?

2.18.0

What operating system are you using?

Windows

Describe the Bug

Whenever I run โ€œwrangler devโ€ I get the following error:

[ERROR] Error while creating remote dev session: TypeError: fetch failed

at fetch (\my-test-api\node_modules\wrangler\wrangler-dist\cli.js:16584:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async createPreviewSession (\my-test-api\node_modules\wrangler\wrangler-dist\cli.js:132585:28) at async start (\my-test-api\node_modules\wrangler\wrangler-dist\cli.js:151229:9) { cause: ConnectTimeoutError: Connect Timeout Error at onConnectTimeout (\my-test-api\node_modules\wrangler\wrangler-dist\cli.js:7185:29) at \my-test-api\node_modules\wrangler\wrangler-dist\cli.js:7141:51 at Immediate._onImmediate (\my-test-api\node_modules\wrangler\wrangler-dist\cli.js:7171:37) at process.processImmediate (node:internal/timers:476:21) { code: โ€˜UND_ERR_CONNECT_TIMEOUTโ€™ } }

This is a brand new project with wrangler init, but when I ran wrangler dev it had the same error. Project has only the initial project changes nothing has been modified after the project is created . with -l local run is fine.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 20 (5 by maintainers)

Most upvoted comments

Hey everyone! ๐Ÿ‘‹ As an update, weโ€™ve identified a potential cause for the errors that are coming from the service registry (Failed to register worker in local service registry, Failed to get worker definitions, Failed to unregister worker) and will aim to get a fix out in the next few weeks. ๐Ÿ‘

As a quick update for people following this issue, we have a PR that could fix this problem in most cases (#4241), but weโ€™re going to hold off merging it until some other work to rearchitect Wrangler-as-a-library is complete (#4413). ๐Ÿ‘

So I suddenly started getting this which is weird because I dont recall changing anything. One second it wasnโ€™t there and suddenly it was

$ npx wrangler dev
wrangler dev now uses local mode by default, powered by ๐Ÿ”ฅ Miniflare and ๐Ÿ‘ท workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Using vars defined in .dev.vars
Your worker has access to the following bindings:
- Vars:
  - WISE_TOKEN: "(hidden)"
  - VERBOSE: "(hidden)"
โŽ” Starting local server...
[mf:inf] Ready on http://127.0.0.1:8787/
โœ˜ [ERROR] Failed to register worker in local service registry TypeError: fetch failed

      at fetch
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:16584:17)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async registerWorker
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:126327:12)
      at async MiniflareServer.<anonymous>
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:127987:9) {
    cause: ConnectTimeoutError: Connect Timeout Error
        at onConnectTimeout
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7185:29)
        at
  /home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7141:51
        at Immediate._onImmediate
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7173:13)
        at process.processImmediate (node:internal/timers:476:21) {
      code: 'UND_ERR_CONNECT_TIMEOUT'
    }
  }


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

      at fetch
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:16584:17)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async getRegisteredWorkers
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:126361:22)
      at async getBoundRegisteredWorkers
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:126380:29)
  {
    cause: ConnectTimeoutError: Connect Timeout Error
        at onConnectTimeout
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7185:29)
        at
  /home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7141:51
        at Immediate._onImmediate
  (/home/rhahkeem/Code/wrangler/lifestuff-web/node_modules/wrangler/wrangler-dist/cli.js:7173:13)
        at process.processImmediate (node:internal/timers:476:21) {
      code: 'UND_ERR_CONNECT_TIMEOUT'
    }
  }

Using โ›…๏ธ wrangler 3.5.1

Hello. PM for the Wrangler team ๐Ÿ‘‹ I have a few questions about this issue that would be really helpful to get answers to:

  • Does this happen on never versions of Wrangler as well? Could you try with a more recent version than 2.19?
  • Does this happen only when using wrangler dev for remote development?
  • Has anyone seen these issues in v3?