question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`wrangler dev` fails when `workers_dev = true` and custom routes are specified

See original GitHub issue

Reproduce the bug

It’s very simple. I have a rust project, and I have run this with wrangler.toml.

name = "do-ws"
workers_dev = true

main = "build/worker/shim.mjs"
compatibility_date = "2022-01-20"

routes = [
    { pattern = "u-tygra-dev.api.pajkovsky.io", custom_domain = true, zone_id = "..." }
]

[build]
command = "cargo install -q worker-build --version 0.0.7 && worker-build --release"

[durable_objects]
bindings = [
  { name = "WEBSOCKETS", class_name = "WebSocketStore" }
]

[[migrations]]
tag = "v1"
new_classes = ["WebSocketStore"]

[env.prod]
name = "do-ws-prod"
workers_dev = false
routes = [
    { pattern = "u-tygra.api.pajkovsky.io", custom_domain = true, zone_id = "..." }
]
vars = { ENVIRONMENT = "prod" }
durable_objects.bindings = [
  {name = "WEBSOCKETS", class_name = "WebSocketStore", script_name = "do-ws-prod"}
]

And running wrangler dev fails with error

- http://192.168.1.244:8787
✘ [ERROR] Error while creating remote dev session: TypeError: fetch failed

      at Object.processResponse
  (/Users/npajkovsky/freelancer/u-tygra/be/node_modules/wrangler/wrangler-dist/cli.js:8846:27)
      at /Users/npajkovsky/freelancer/u-tygra/be/node_modules/wrangler/wrangler-dist/cli.js:9178:42
      at node:internal/process/task_queues:141:7
      at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
      at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    cause: Error: getaddrinfo ENOTFOUND pajkovsky.io
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
      errno: -3008,
      code: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: 'pajkovsky.io'
    }
  }

Environment and versions

  • operating system: Linux/Mac
  • output of wrangler -V:
 ⛅️ wrangler 2.1.11
--------------------
  • output of node -v: v16.16.0

Why am I getting this error?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
penalosacommented, Nov 24, 2022

I believe this is because we make some requests to the route zone (prewarm, I think, and possibly others). A quick win could be to find those requests and make them to the custom route instead. A workaround for now is to make sure that your root zone resolves to something, but this is definitely something we’ll fix.

0reactions
ahaoboycommented, Nov 8, 2022

Same issue.

git clone https://github.com/ahaoboy/v8-cf.git

cd v8-cf

pnpm i

pnpm run dev

// Error while creating remote dev session: TypeError: fetch failed

System: OS: macOS 13.0 Binaries: Node: 18.9.0 - ~/Library/Caches/fnm_multishells/60050_1667356309613/bin/node Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/60050_1667356309613/bin/yarn npm: 8.19.1 - ~/Library/Caches/fnm_multishells/60050_1667356309613/bin/npm Browsers: Chrome: 107.0.5304.87 Edge: Not Found Firefox: Not Found Safari: 16.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrangler dev in 11.0 is non-functional when there are ... - GitHub
I have a worker deployed with a very broad/non-specific route, *example.com/* . It handles some generic redirect behavior. I have other workers ......
Read more >
Environments · Cloudflare Workers docs
Wrangler will fail to deploy when both workers_dev = true and route (or routes ) are defined. If you are trying to deploy...
Read more >
Detecting if we are running in dev mode or in production mode ...
I need to know in my worker script if ...
Read more >
Preview and Publish Your Cloudflare Workers Project
Using the wrangler dev command we can look at our Workers serverless function and test ... Deploy to a Custom Domain with Cloudflare...
Read more >
Build a Link Shortener with Cloudflare Workers: Deployment
<yoursubdomain>.workers.dev , where name is the project name you defined in the wrangler.toml name key, and yoursubdomain is your Workers ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found