cloudflare / workers-sdk

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

๐Ÿ› BUG: Using both `--route` and `--remote` causes WebSocket error #3755

Closed helloimalastair closed 6 months ago

helloimalastair commented 1 year ago

Which Cloudflare product(s) does this pertain to?

Wrangler core

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

3.5.0

What version of Node are you using?

20.5.1

What operating system are you using?

macOS Ventura 13.5

Describe the Bug

  1. Create index.js file:
    export default {
    fetch(req) {
        const url = new URL(req.url);
        return new Response(`Your hostname is: ${url.hostname}`);
    }
    }
  2. Run Wrangler Dev with both --remote and --route flags(with a zone you have access to):
    
    $ wrangler dev index.js --route "goalastair.com/*" --remote
    โ›…๏ธ wrangler 3.5.0
    ------------------
    โฌฃ Listening at http://0.0.0.0:8787
    - http://127.0.0.1:8787
    - http://192.168.32.2:8787
    Total Upload: 5.96 KiB / gzip: 1.84 KiB
    โ–ฒ [WARNING] worker failed to prewarm:  Bad Gateway

Waiting for connection... โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ [b] open a browser, [d] open Devtools, [l] turn on local mode, [c] clear console, [x] to exit โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ /Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:30632 throw a; ^

Error: WebSocket was closed before the connection was established at WebSocket2.close (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:108521:11) at close (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:127122:14) at /Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:127230:7 at jh (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:29688:15) at exports2.unstable_runWithPriority (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:25660:16) at Pc (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:26308:16) at Qg (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:29651:18) at /Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:29640:13 at V (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:25585:22) at Timeout.w [as _onTimeout] (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:25420:13) Emitted 'error' event on WebSocket instance at: at emitErrorAndClose (/Project/Directory/node_modules/.pnpm/registry.npmjs.org+wrangler@3.5.0/node_modules/wrangler/wrangler-dist/cli.js:108968:17) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Node.js v20.5.1



### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

_No response_
iksaku commented 10 months ago

Been waiting on this issue for some months now as well. My workaround was to comment out [route] definition from wrangler.toml each time I was running my projects locally, but also needed to remember to un-comment before any commits/deploys...

Just discovered today that you can pass --routes=[] on your command via package.json scripts and it will overwrite the definition from wrangler.toml.

So, the config may look like this:

wrangler.toml:

name = "my-worker"
main = "src/worker.ts"
compatibility_date = "2023-10-23"

workers_dev = false

[route]
  pattern = "worker.example.com"
  custom_domain = true

package.json:

{
  "scripts": {
    "dev": "wrangler dev --remote --routes=[]"
  }
}

Hopefully we can get come kind fix, or at least, a flag to bypass routes when using --remote.

penalosa commented 10 months ago

@helloimalastair @iksaku I'm unable to reproduce this in either the latest Wrangler or Wrangler 3.5. A couple questions to help debug this:

helloimalastair commented 10 months ago

@penalosa

  1. Using Access? No
  2. Orange-Clouded? Yes
  3. Logged in? Yes

Just did some digging, and it looks like goalastair.com is subject to a Bulk Redirect rule, and if I switch to www.goalastair.com, it does work. Also found a separate bug, in that when hitting the b key to open in browser, it spawns www.goalastair.com:8787

penalosa commented 10 months ago

Thanks @helloimalastair โ€”in that case I'll close this issue. The hotkey bug is captured in https://github.com/cloudflare/workers-sdk/issues/3907, I think

helloimalastair commented 10 months ago

@penalosa So wait, is it expected that --remote doesn't work when rules are applied to the target? Or should that be documented somewhere?

penalosa commented 10 months ago

--remote should follow the same logic as deployed workers, as far as I know. Because redirect rules run before Workers, if you have:

Accessing source.example.com won't execute your worker. You'd have to give the worker a route of target.example.com (the target of the redirect rule) for the worker to execute.

In the same way, I think it's expected behaviour that you need to provide www.goalastair.com/* rather than goalastair.com/* as the route if that's the ultimate target of the redirect rule, and the route set up on your deployed worker.

lucas-pelton commented 10 months ago

The OP may have a redirect rule set up that's not a best practice and is leading to this error...

I have a similar error, but without the redirect rules. My setup is this

If I have any routes in my wrangler.toml is when the OP's bug surfaces. If I add routes via the dashboard and comment out the routes in wrangler.toml, I'm able to get wrangler dev --remote running (or wrangler dev, press l to turn off local)

Interestingly, the error message is different if I use the --remote flag vs switching to remote. Switching to remote actually throws an error that was mentioned in a bug closed for Wrangler v2. I can provide more details here or elsewhere if this piques anyone's interest.

penalosa commented 10 months ago

@lucas-pelton Would you be able to file a new issue with more details, and the exact error messages you're receiving? That sounds like a bug we should fix

lucas-pelton commented 10 months ago

Let me put together a proper test and report using a domain that's not running live services. It may be a minute, but I'll do it.

iksaku commented 10 months ago

Hello @penalosa,

  1. Not using CF Access.
  2. DNS entry is indeed orange-clouded as it shows is being proxied to my worker.
  3. Yes, I'm logged in to the account owning the zone and worker.

In my case, I have no bulk redirects nor page rules configured for the zone, so a redirection misconfiguration should not be the problem here. Also, I'm using a subdomain for my worker, not the root domain, and the wrangler.toml looks like this:

name = "my-worker"
main = "src/worker.ts"
compatibility_date = "2023-10-23"

workers_dev = false

[[r2_buckets]]
  binding = "BUCKET"
  bucket_name = "..."
  preview_bucket_name = "..."

[route]
  pattern = "worker.<my-domain>.com"
  custom_domain = true

Any ideas?

lucas-pelton commented 10 months ago

@iksaku The Wrangler docs suggest you can't have these in the same config:

workers_dev = false

[route]
  pattern = "worker.<my-domain>.com"
  custom_domain = true

Specifically

If you change your routes in the dashboard, Wrangler will override them in the next deploy with the routes you have set in your wrangler.toml. To manage routes via the Cloudflare dashboard only, remove any route and routes keys from your wrangler.toml file. Then add workers_dev = false to your wrangler.toml file. https://developers.cloudflare.com/workers/wrangler/configuration/

Is this related to your use of wrangler dev --routes=[] workaround?

iksaku commented 10 months ago

I must've skipped that in the docs.

And yes, this is related to my workaround

penalosa commented 10 months ago

@lucas-pelton those two items are fine to co-exist in a wrangler.toml file. Those docs are specifically referring to if you want to only manage your routes through the Cloudflare dashboard. We can definitely clarify them if that's not clear though.

@iksaku what's the output you get from wrangler dev --remote, and what's your account ID? I can take a look to see what might be going on?

(re-opening this to keep investigating)

iksaku commented 10 months ago

@penalosa Sure! My account ID is df4989e4945becf8236d033213f17af8.

Attached error log ``` > wrangler dev --remote โ›…๏ธ wrangler 3.14.0 ------------------- Your worker has access to the following bindings: - R2 Buckets: - BUCKET: ... โฌฃ Listening at http://0.0.0.0:8787 - http://127.0.0.1:8787 - http://192.168.1.81:8787 - http://100.70.222.84:8787 - http://198.19.249.3:8787 Total Upload: 48.00 KiB / gzip: 11.86 KiB Waiting for connection... Error: WebSocket was closed before the connection was established at WebSocket2.close (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:107657:18) at close (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:127819:14) at ./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:127880:7 at jh (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:28430:15) at exports2.unstable_runWithPriority (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:24402:16) at Pc (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:25050:16) at Qg (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:28393:18) at ./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:28382:13 at V (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:24327:22) at Timeout.w [as _onTimeout] (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:24162:13) Emitted 'error' event on WebSocket instance at: at emitErrorAndClose (./node_modules/.pnpm/wrangler@3.14.0/node_modules/wrangler/wrangler-dist/cli.js:108144:17) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) ```

If I instead run using my workaround (wrangler dev --remote --routes=[]) or directly comment out the [route] definition in my wrangler.toml file, the error in question disappears and the worker keeps working as intended.

Thank you!

lucas-pelton commented 10 months ago

@iksaku I get a very similar error log running wrangler dev --remote, but if I run wrangler dev and then press l to switch from local to remote, the error is significantly different.

This JSON parsing error is the one that I mentioned in an earlier post that is similar to the Wrangler v2 bug at #2581 (at least in that they're trying to JSON.parse an HTML file when trying launch a remote dev server.

Stack trace:

โœ˜ [ERROR] Error while creating remote dev session: ParseError: Unexpected token <

      at parseJSON
  (/home/runcloud/wrangler-projects/telcom-processor/node_modules/wrangler/wrangler-dist/cli.js:119580:11)
      at createPreviewSession
  (/home/runcloud/wrangler-projects/telcom-processor/node_modules/wrangler/wrangler-dist/cli.js:150592:51)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async start
  (/home/runcloud/wrangler-projects/telcom-processor/node_modules/wrangler/wrangler-dist/cli.js:150781:9)

My HTML file is a cloudflare error page - Error 1031: Improperly configured Workers Preview for dev-telcom.eaevsf.us. You may need to reinitialize.

Interestingly, I've commented out routes in wrangler.toml and I'm getting this error when switching to remote, but not when using the --remote flag.

This is occurring on the sub.domain/ worker while I have a domain.com/ worker manually configured on the dashboard. (This is the live services setup, so I can't test the effect of taking down the domain.com/* route binding.

flexchar commented 8 months ago

This is extremely frustrating as workerd is still encountering some issues that are not present when deployed. I'd really appreciate this being looked on more.

I often get: โš ๏ธ [WARNING] worker failed to prewarm: Bad Gateway OR

โœ˜ [ERROR] Error while creating remote dev session: ParseError: Unexpected token < 
 at parseJSON

The workaround using npx wrangler dev --remote --routes "[]" does help :)

penalosa commented 7 months ago

@lucas-pelton @iksaku @flexchar We've recently added some more error reporting into Wrangler, which should significantly help with debugging this. Would one of you be able to upload the error log that Wrangler outputs at the end of a run?

flexchar commented 7 months ago

Hey Somhairle, I launched as typical and pressed l to disable local mode receiving exact same error/output. I'm on the 3.25.0 version. Where should I look for the new logs?

If those are the ones from the file upon exit, then here you are - I redacted any hashes/ids of my own. :)

Logs --- 2024-01-27T06:58:29.331Z debug ๐Ÿชต Writing logs to "/Users/path/Library/Preferences/.wrangler/logs/wrangler-2024-01-27_06-58-29_265.log" --- --- 2024-01-27T06:58:29.331Z debug Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env' at Object.openSync (node:fs:581:18) at Object.readFileSync (node:fs:457:35) at tryLoadDotEnv (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:124241:72) at loadDotEnv (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:124250:12) at /Users/path/node_modules/wrangler/wrangler-dist/cli.js:162325:20 at /Users/path/node_modules/wrangler/wrangler-dist/cli.js:131115:16 at maybeAsyncResult (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:129336:44) at /Users/path/node_modules/wrangler/wrangler-dist/cli.js:131114:14 at /Users/path/node_modules/wrangler/wrangler-dist/cli.js:129323:22 at Array.reduce () { errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' } --- --- 2024-01-27T06:58:29.986Z log โ›…๏ธ wrangler 3.25.0 ------------------- --- --- 2024-01-27T06:58:29.999Z debug Retrieving cached values for userId from node_modules/.cache/wrangler --- --- 2024-01-27T06:58:29.999Z debug Metrics dispatcher: Posting data {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}} --- --- 2024-01-27T06:58:30.003Z log Using vars defined in .dev.vars --- --- 2024-01-27T06:58:30.003Z log Your worker has access to the following bindings: - KV Namespaces: - ... - ... - ... - D1 Databases: - ... - R2 Buckets: -... - Vars: - IS_DEV: "(hidden)" ... - CF_SERVICE_CLIENT_SECRET: "(hidden)" --- --- 2024-01-27T06:58:30.092Z log โŽ” Starting local server... --- --- 2024-01-27T06:58:31.043Z debug [InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadStart"} --- --- 2024-01-27T06:58:31.044Z debug [InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadComplete","proxyData":{"userWorkerUrl":{"protocol":"http:","hostname":"127.0.0.1","port":"52338"},"userWorkerInspectorUrl":{"protocol":"ws:","hostname":"127.0.0.1","port":"52328","pathname":"/core:user:worker"},"userWorkerInnerUrlOverrides":{"protocol":"http","hostname":"example.com","port":""},"headers":{"MF-Proxy-Shared-Secret":"..."},"liveReload":false,"proxyLogsToController":false,"internalDurableObjects":[]}} --- --- 2024-01-27T06:58:31.045Z debug [InspectorProxyWorker] reconnectRuntimeWebSocket --- --- 2024-01-27T06:58:31.046Z debug [InspectorProxyWorker] NEW RUNTIME WEBSOCKET http://127.0.0.1:52328/core:user:worker --- --- 2024-01-27T06:58:31.047Z debug [InspectorProxyWorker] SEND TO DEVTOOLS {"method":"Runtime.executionContextsCleared"} --- --- 2024-01-27T06:58:31.047Z debug [InspectorProxyWorker] RUNTIME WEBSOCKET OPENED --- --- 2024-01-27T06:58:31.048Z debug [InspectorProxyWorker] SEND TO RUNTIME {"method":"Runtime.enable","id":100000001} --- --- 2024-01-27T06:58:31.048Z debug [InspectorProxyWorker] SEND TO RUNTIME {"method":"Debugger.enable","id":100000002} --- --- 2024-01-27T06:58:31.048Z debug [InspectorProxyWorker] SEND TO RUNTIME {"method":"Network.enable","id":100000003} --- --- 2024-01-27T06:58:31.069Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { method: 'Runtime.executionContextCreated', params: { context: { id: 97084897, origin: '', name: 'Worker', uniqueId: '...' } } } --- --- 2024-01-27T06:58:31.069Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000001, result: {} } --- --- 2024-01-27T06:58:31.069Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { method: 'Debugger.scriptParsed', params: { scriptId: '3', url: 'file:///Users/path/.wrangler/tmp/dev-XXuViP/routes.js', startLine: 0, startColumn: 0, endLine: 30893, endColumn: 86, executionContextId: 97084897, hash: '...', isLiveEdit: false, sourceMapURL: 'routes.js.map', hasSourceURL: true, isModule: true, length: 1082665, scriptLanguage: 'JavaScript', embedderName: 'routes.js' } } --- --- 2024-01-27T06:58:31.069Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { method: 'Debugger.scriptParsed', params: { scriptId: '4', url: 'cloudflare-internal:d1-api', startLine: 0, startColumn: 0, endLine: 218, endColumn: 0, executionContextId: 97084897, hash: '...', isLiveEdit: false, sourceMapURL: '', hasSourceURL: false, isModule: true, length: 7450, scriptLanguage: 'JavaScript', embedderName: 'cloudflare-internal:d1-api' } } --- --- 2024-01-27T06:58:31.070Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000002, result: { debuggerId: '-4236963097810129257.3658180306492163969' } } --- --- 2024-01-27T06:58:31.070Z debug [InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000003, method: 'Network.enable', result: {} } --- --- 2024-01-27T06:58:32.529Z log โŽ” Shutting down local server... --- --- 2024-01-27T06:58:32.534Z debug Checking if domain has Access enabled: dash.cloudflare.com --- --- 2024-01-27T06:58:32.534Z debug Access switch not cached for: dash.cloudflare.com --- --- 2024-01-27T06:58:32.542Z debug [InspectorProxyWorker] RUNTIME WEBSOCKET CLOSED 1006 WebSocket disconnected without sending Close frame. --- --- 2024-01-27T06:58:32.597Z debug [InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadStart"} --- --- 2024-01-27T06:58:32.662Z debug Caching access switch for: dash.cloudflare.com --- --- 2024-01-27T06:58:33.262Z debug -- START CF API REQUEST: GET https://api.cloudflare.com/client/v4/accounts/...../workers/subdomain/edge-preview --- --- 2024-01-27T06:58:33.262Z debug HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:33.262Z debug INIT: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:33.262Z debug -- END CF API REQUEST --- --- 2024-01-27T06:58:35.153Z debug -- START CF API RESPONSE: OK 200 --- --- 2024-01-27T06:58:35.154Z debug HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:35.154Z debug RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:35.154Z debug -- END CF API RESPONSE --- --- 2024-01-27T06:58:35.154Z debug -- START EXCHANGE API REQUEST: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:35.154Z debug -- END EXCHANGE API REQUEST --- --- 2024-01-27T06:58:35.222Z debug -- START EXCHANGE API RESPONSE: Bad Request 400 --- --- 2024-01-27T06:58:35.222Z debug HEADERS: {} --- --- 2024-01-27T06:58:35.222Z debug RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data --- --- 2024-01-27T06:58:35.222Z debug -- END EXCHANGE API RESPONSE --- --- 2024-01-27T06:58:35.263Z error โœ˜ [ERROR] Error while creating remote dev session: SyntaxError: Unexpected token '<', ") at parseJSON (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:119388:17) at createPreviewSession (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:164891:51) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async start (/Users/path/node_modules/wrangler/wrangler-dist/cli.js:165442:9) --- --- 2024-01-27T06:58:39.333Z debug Not Implemented Error: ConfigController#teardown --- --- 2024-01-27T06:58:39.333Z debug Not Implemented Error: BundlerController#teardown --- --- 2024-01-27T06:58:39.333Z debug Not Implemented Error: LocalRuntimeController#teardown --- --- 2024-01-27T06:58:39.333Z debug Not Implemented Error: RemoteRuntimeController#teardown --- --- 2024-01-27T06:58:39.334Z debug ProxyController teardown ---
lucas-pelton commented 7 months ago

npm create cloudflare@latest -> Hello World Worker

wrangler.toml

name = "remote-dev-test"
main = "src/index.js"
compatibility_date = "2024-01-17"
account_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
workers_dev = false
route = { pattern = "worker.xxxxx.com", custom_domain = true }

GET https://worker.xxxx.com -> Hello World!

npx wrangler dev
 โ›…๏ธ wrangler 3.25.0
-------------------
โŽ” Starting local server...
[wrangler:inf] Ready on http://localhost:8787

OK! Press 'l' to turn off local mode:

โŽ” Shutting down local server...
โœ˜ [ERROR] Error while creating remote dev session: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

      at JSON.parse (<anonymous>)
      at parseJSON
  (/home/runcloud/projects/wrangler/remote-dev-test/node_modules/wrangler/wrangler-dist/cli.js:119388:17)
      at createPreviewSession
  (/home/runcloud/projects/wrangler/remote-dev-test/node_modules/wrangler/wrangler-dist/cli.js:164891:51)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async start
  (/home/runcloud/projects/wrangler/remote-dev-test/node_modules/wrangler/wrangler-dist/cli.js:165442:9)

npx wrangler dev --remote
 โ›…๏ธ wrangler 3.25.0
-------------------
[wrangler:inf] Ready on http://localhost:8787
Total Upload: 1.15 KiB / gzip: 0.63 KiB

OK!

turn ON local mode. OK turn OFF local mode. OK


npx wrangler dev Local starts OK, turn OFF local mode throws same error as above.

wrangler-2024-01-29_17-05-13_976.log

penalosa commented 6 months ago

@lucas-pelton this should be fixed in #5107