cloudflare / workers-sdk

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

๐Ÿ› BUG: Unable to run wrangler dev since version 3.19.0 #4921

Closed lnewson closed 6 months ago

lnewson commented 7 months ago

Which Cloudflare product(s) does this pertain to?

Wrangler core

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

3.26.0

What version of Node are you using?

20.11.0

What operating system and version are you using?

macOS Sonoma 14.3

Describe the Bug

Observed behavior

Since version 3.19.0 of wrangler was released we're no longer able to run wrangler dev --remote. It runs, but as soon as a page is viewed the following error is thrown:

โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }

Expected behavior

Work as it did in version 3.18.0 and lower.

Steps to reproduce

Due to the code being internal, I cannot provide an exact example. Happy to provide any debug logs that might be useful. The error happens 100% of the time by just running wrangler dev --remote and then opening http://localhost:8787 in a browser (or pressing b).

In case it's applicable, we have these compatibility settings in wrangler.toml. In saying that though I can replicate by removing both of these.

compatibility_date = "2022-09-01"
compatibility_flags = ["url_standard"]

Potentially worth noting is that I've added a console.log in the exported fetch function to see if our worker code ever runs but it doesn't appear to (or at least the log message is never printed).

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

I've redacted some parts that I didn't want public and replaced it with placeholder strings (e.g. <ACCOUNT>).


--- 2024-02-05T02:02:55.251Z debug
๐Ÿชต  Writing logs to "/Users/lnewson/Library/Preferences/.wrangler/logs/wrangler-2024-02-05_02-02-55_173.log"
---

--- 2024-02-05T02:02:55.251Z 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/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:124257:72)
    at loadDotEnv (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:124266:12)
    at /Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:162342:20
    at /Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:131131:16
    at maybeAsyncResult (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:129352:44)
    at /Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:131130:14
    at /Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:129339:22
    at Array.reduce (<anonymous>) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.env'
}
---

--- 2024-02-05T02:02:55.257Z log
 โ›…๏ธ wrangler 3.26.0
-------------------
---

--- 2024-02-05T02:02:55.260Z log
Running custom build: yarn test && yarn build
---

--- 2024-02-05T02:02:57.657Z debug
Retrieving cached values for userId from node_modules/.cache/wrangler
---

--- 2024-02-05T02:02:57.657Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":false,"usesTypeScript":false}}.
---

--- 2024-02-05T02:02:57.657Z debug
Failed to load .env file "/Users/lnewson/site/cloudflare/worker/.dev.vars": Error: ENOENT: no such file or directory, open '/Users/lnewson/site/cloudflare/worker/.dev.vars'
    at Object.openSync (node:fs:581:18)
    at Object.readFileSync (node:fs:457:35)
    at tryLoadDotEnv (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:124257:72)
    at loadDotEnv (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:124266:12)
    at getVarsForDev (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:166550:18)
    at getBindings (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:167559:10)
    at getBindingsAndAssetPaths (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:167515:20)
    at getDevReactElement (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:167181:40)
    at startDev (/Users/lnewson/site/cloudflare/worker/node_modules/wrangler/wrangler-dist/cli.js:167244:60)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/lnewson/site/cloudflare/worker/.dev.vars'
}
---

--- 2024-02-05T02:02:57.686Z debug
-- START CF API REQUEST: GET https://api.cloudflare.com/client/v4/accounts/<ACCOUNT>/workers/subdomain/edge-preview
---

--- 2024-02-05T02:02:57.686Z debug
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:57.686Z debug
INIT: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:57.686Z debug
-- END CF API REQUEST
---

--- 2024-02-05T02:02:57.824Z debug
[InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadStart"}
---

--- 2024-02-05T02:02:58.264Z debug
-- START CF API RESPONSE: OK 200
---

--- 2024-02-05T02:02:58.264Z debug
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.264Z debug
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.264Z debug
-- END CF API RESPONSE
---

--- 2024-02-05T02:02:58.265Z debug
-- START EXCHANGE API REQUEST: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.265Z debug
-- END EXCHANGE API REQUEST
---

--- 2024-02-05T02:02:58.396Z debug
-- START EXCHANGE API RESPONSE: OK 200
---

--- 2024-02-05T02:02:58.396Z debug
HEADERS: {}
---

--- 2024-02-05T02:02:58.396Z debug
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.396Z debug
-- END EXCHANGE API RESPONSE
---

--- 2024-02-05T02:02:58.422Z log
Total Upload: 89.31 KiB / gzip: 18.90 KiB
---

--- 2024-02-05T02:02:58.423Z debug
-- START CF API REQUEST: POST https://api.cloudflare.com/client/v4/accounts/<ACCOUNT>/workers/scripts/dev_docs-prod/edge-preview
---

--- 2024-02-05T02:02:58.423Z debug
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.423Z debug
INIT: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:58.423Z debug
-- END CF API REQUEST
---

--- 2024-02-05T02:02:59.729Z debug
-- START CF API RESPONSE: OK 200
---

--- 2024-02-05T02:02:59.730Z debug
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:59.730Z debug
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
---

--- 2024-02-05T02:02:59.730Z debug
-- END CF API RESPONSE
---

--- 2024-02-05T02:02:59.730Z debug
Checking if domain has Access enabled: <DOMAIN>
---

--- 2024-02-05T02:02:59.730Z debug
Access switch not cached for: <DOMAIN>
---

--- 2024-02-05T02:02:59.760Z debug
Caching access switch for: <DOMAIN>
---

--- 2024-02-05T02:02:59.766Z debug
Checking if domain has Access enabled: <DOMAIN>
---

--- 2024-02-05T02:02:59.766Z debug
Access switch not cached for: <DOMAIN>
---

--- 2024-02-05T02:02:59.905Z debug
Caching access switch for: <DOMAIN>
---

--- 2024-02-05T02:02:59.915Z debug
[InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadComplete","proxyData":{"userWorkerUrl":{"protocol":"https:","hostname":"<DOMAIN>","port":"443"},"userWorkerInspectorUrl":{"protocol":"wss:","hostname":"<DOMAIN>","port":"","pathname":"/cdn-cgi/workers/preview/inspector"},"userWorkerInnerUrlOverrides":{},"headers":{"cf-workers-preview-token":"AU9fF1RhfYQtv5yO0s8Ywz5HjouYhxd7PuhyNQwgEukUkOchT9TiRIL5LyFnn2UkdcwBp9hQ8adrZ9tVFFOqFQk6UhaO8xU25YiYbse7yxoizSystaE8emx1pNajdTCfQ7NCzu3cl8GGofkr2eQ1G9H89vSNfX7tNBg_iJiBa0qjLqH0JZCV8rooU1K4cjso3mLyQ1SwxK5UDbQvhYpnteM-KuXCdqSR6NlwCk8KR19v9xf0Vfcg1_Js_Xa0x92-ZdVrzmn1TjcVhZjw5HX6d9C3sOpoA2QGnDbkCYIF1OnEsamnKwpUSD4QcjQSj2dj3QlAx1n_qhUpAkT2DS3pMHYceXvAzsNJZiQ7at8w1d-MSK8sQjerNeNoMSbDJ2jt7LE_mO9RAa9gO9X8D6oN96_01yqFb7W-6354eH7DnO-1aDBRL-ITgGOh697OK15GZeXytqZmHqzi01mf9fsGtFCV7ujE1yuUlUt_nXihCHK8aJ2_3t5cohAzazc_MC7eXlQONxbZyNZo2f0qz17-RfMYSN3m2pjr4Vwfhjv1iJt6nDyKEJ_JIw1rp2zizc6-LH-HamKeaRx7Pk8RvYe-r5Di1d62X-qDSxSTYJsoeN6mvCW7tBasqyMxklgzifvgouyzg2dt0LXfarVADFktCZ1cbaQv5Dhudwa0J1RVU7WZA8gEI8HNUkTr8tD37TEFkJGulRahM8Y4qMj0epsryPo43nW-6VmroawjMJCr7m6kU85vlsN4RSfed4RkyjM_Ki32SxLFs-acVa5WDPJvTE2zcCcdC9v0rZilm5srQNSQjR7WPjUXzVTr0qXSSZeuCRD5M5Uq_SHUSPidcu3YrtYUnagKg9KjC2IxkLqFAE25rZ0J1sASTTi3idmYqqryqHLwJckQgoQP3Mr2d5WgBQPEQ4jYj3uLrw-FITJDuYFQvah0wlDeXHVv2NPYz8PPisyVWxFHZx34HIyqxx-FkBW5MWLD2_oNQbLB01q-pxxaf36zx179vTquoNKI0LIEbsErfbi5K0L6DGukAJuqazg"},"liveReload":false,"proxyLogsToController":true}}
---

--- 2024-02-05T02:02:59.916Z debug
[InspectorProxyWorker] reconnectRuntimeWebSocket
---

--- 2024-02-05T02:02:59.917Z debug
[InspectorProxyWorker] NEW RUNTIME WEBSOCKET https://<DOMAIN>/cdn-cgi/workers/preview/inspector
---

--- 2024-02-05T02:02:59.918Z debug
[InspectorProxyWorker] SEND TO DEVTOOLS {"method":"Runtime.executionContextsCleared"}
---

--- 2024-02-05T02:03:00.523Z debug
workerd/util/symbolizer.c++:96: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=<path>`.
workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = Hostname mismatch
stack: 1038a2c83 1038a32b7 104bd033f 1038aabe8 104bfabb8 104bfb000 1039c3a9b 1039c438b 1039c5a87 1039a319c 1039a9d44 1039bff20 102b978cc 103148bdc; sentryErrorContext = jsgInternalError
---

--- 2024-02-05T02:03:00.562Z error
โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }

---

--- 2024-02-05T02:03:00.563Z debug
=> Error contextual data: {
  config: {
    name: 'dev_docs-prod',
    script: { contents: '' },
    dev: {
      server: [Object],
      inspector: [Object],
      urlOverrides: [Object],
      liveReload: false
    }
  },
  bundle: {
    id: 0,
    entry: {
      file: '/Users/lnewson/site/cloudflare/worker/build/index.js',
      directory: '/Users/lnewson/site/cloudflare/worker',
      format: 'modules',
      moduleRoot: '/Users/lnewson/site/cloudflare/worker/build',
      name: 'dev_docs-prod'
    },
    path: '/Users/lnewson/site/cloudflare/worker/.wrangler/tmp/dev-dJD68W/index.js',
    type: 'esm',
    modules: [],
    dependencies: {
      '.wrangler/tmp/bundle-Y06h6i/checked-fetch.js': [Object],
      'build/index.js': [Object]
    },
    sourceMapPath: '.wrangler/tmp/dev-dJD68W/index.js.map',
    sourceMapMetadata: {
      tmpDir: '/Users/lnewson/site/cloudflare/worker/.wrangler/tmp/bundle-Y06h6i',
      entryDirectory: '/Users/lnewson/site/cloudflare/worker'
    }
  }
}
---

--- 2024-02-05T02:03:00.673Z debug
[InspectorProxyWorker] RUNTIME WEBSOCKET OPENED
---

--- 2024-02-05T02:03:00.674Z debug
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Runtime.enable","id":100000001}
---

--- 2024-02-05T02:03:00.674Z debug
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Debugger.enable","id":100000002}
---

--- 2024-02-05T02:03:00.674Z debug
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Network.enable","id":100000003}
---

--- 2024-02-05T02:03:00.704Z debug
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  method: 'Runtime.executionContextCreated',
  params: {
    context: {
      id: 1,
      origin: '',
      name: 'Worker',
      uniqueId: '-6374973205721458888.-7824425677934341909'
    }
  }
}
---

--- 2024-02-05T02:03:00.704Z debug
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000001, result: {} }
---

--- 2024-02-05T02:03:00.705Z debug
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  method: 'Debugger.scriptParsed',
  params: {
    scriptId: '3',
    url: 'file:///Users/lnewson/site/cloudflare/worker/.wrangler/tmp/dev-dJD68W/index.js',
    startLine: 0,
    startColumn: 0,
    endLine: 2667,
    endColumn: 101,
    executionContextId: 1,
    hash: '8e99dbf3c9140b0e379af69d701de87f7741316c74b40a77c63d7831277d7288',
    isLiveEdit: false,
    sourceMapURL: 'index.js.map',
    hasSourceURL: true,
    isModule: true,
    length: 91451,
    scriptLanguage: 'JavaScript',
    embedderName: 'index.js'
  }
}
---

--- 2024-02-05T02:03:00.705Z debug
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  id: 100000002,
  result: { debuggerId: '-6861462484141182344.8585576275922833579' }
}
---

--- 2024-02-05T02:03:00.706Z debug
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000003, method: 'Network.enable', result: {} }
---

--- 2024-02-05T02:03:03.066Z debug
Not Implemented Error: ConfigController#teardown
---

--- 2024-02-05T02:03:03.066Z debug
Not Implemented Error: BundlerController#teardown
---

--- 2024-02-05T02:03:03.066Z debug
Not Implemented Error: LocalRuntimeController#teardown
---

--- 2024-02-05T02:03:03.066Z debug
Not Implemented Error: RemoteRuntimeController#teardown
---

--- 2024-02-05T02:03:03.066Z debug
ProxyController teardown
---

Here's an extract of some extra logs by adding --log-level debug of when the error occurs:

[wrangler-ProxyWorker:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (0ms)
-- START CF API RESPONSE: OK 200
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
-- END CF API RESPONSE
-- START EXCHANGE API REQUEST: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
-- END EXCHANGE API REQUEST
-- START EXCHANGE API RESPONSE: OK 200
HEADERS: {}
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
-- END EXCHANGE API RESPONSE
Total Upload: 89.31 KiB / gzip: 18.90 KiB
-- START CF API REQUEST: POST https://api.cloudflare.com/client/v4/accounts/<ACCOUNT>/workers/scripts/dev_docs-prod/edge-preview
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
INIT: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
-- END CF API REQUEST
-- START CF API RESPONSE: OK 200
HEADERS: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
RESPONSE: omitted; set WRANGLER_LOG_SANITIZE=false to include sanitized data
-- END CF API RESPONSE
Checking if domain has Access enabled: <DOMAIN>
Access switch not cached for: <DOMAIN>
Caching access switch for: <DOMAIN>
Checking if domain has Access enabled: <DOMAIN>
Access switch not cached for: <DOMAIN>
Caching access switch for: <DOMAIN>
[InspectorProxyWorker] handleProxyControllerIncomingMessage {"type":"reloadComplete","proxyData":{"userWorkerUrl":{"protocol":"https:","hostname":"<DOMAIN>","port":"443"},"userWorkerInspectorUrl":{"protocol":"wss:","hostname":"<DOMAIN>","port":"","pathname":"/cdn-cgi/workers/preview/inspector"},"userWorkerInnerUrlOverrides":{},"headers":{"cf-workers-preview-token":"<TOKEN>"},"liveReload":false,"proxyLogsToController":true}}
[InspectorProxyWorker] reconnectRuntimeWebSocket
[InspectorProxyWorker] NEW RUNTIME WEBSOCKET https://<DOMAIN>/cdn-cgi/workers/preview/inspector
[InspectorProxyWorker] SEND TO DEVTOOLS {"method":"Runtime.executionContextsCleared"}
[wrangler-ProxyWorker:inf] GET /cdn-cgi/ProxyWorker/play 204 No Content (1ms)
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Runtime.enable","id":100000001}
[InspectorProxyWorker] RUNTIME WEBSOCKET OPENED
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Debugger.enable","id":100000002}
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Network.enable","id":100000003}
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  method: 'Runtime.executionContextCreated',
  params: {
    context: {
      id: 1,
      origin: '',
      name: 'Worker',
      uniqueId: '<UNIQUE_ID>'
    }
  }
}
[InspectorProxyWorker] reconnectRuntimeWebSocket
[InspectorProxyWorker] NEW RUNTIME WEBSOCKET https://<DOMAIN>/cdn-cgi/workers/preview/inspector
[InspectorProxyWorker] SEND TO DEVTOOLS {"method":"Runtime.executionContextsCleared"}
[wrangler-ProxyWorker:inf] GET /cdn-cgi/ProxyWorker/play 204 No Content (1ms)
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Runtime.enable","id":100000001}
[InspectorProxyWorker] RUNTIME WEBSOCKET OPENED
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Debugger.enable","id":100000002}
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Network.enable","id":100000003}
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  method: 'Runtime.executionContextCreated',
  params: {
    context: {
      id: 1,
      origin: '',
      name: 'Worker',
      uniqueId: '-9162096442528856549.1803397986076218078'
    }
  }
}
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000001, result: {} }
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  method: 'Debugger.scriptParsed',
  params: {
    scriptId: '3',
    url: 'file:///Users/lnewson/site/cloudflare/worker/.wrangler/tmp/dev-WWcJsf/index.js',
    startLine: 0,
    startColumn: 0,
    endLine: 2667,
    endColumn: 101,
    executionContextId: 1,
    hash: '17ff3c2389e969cf0a7aa2fb10ad5bab2e5f24f34f6a8b1ea17be9ecaf52b816',
    isLiveEdit: false,
    sourceMapURL: 'index.js.map',
    hasSourceURL: true,
    isModule: true,
    length: 91451,
    scriptLanguage: 'JavaScript',
    embedderName: 'index.js'
  }
}
[InspectorProxyWorker] RUNTIME INCOMING MESSAGE {
  id: 100000002,
  result: { debuggerId: '7465433172647803524.3059957525368977207' }
}

[InspectorProxyWorker] RUNTIME INCOMING MESSAGE { id: 100000003, method: 'Network.enable', result: {} }
[InspectorProxyWorker] SEND TO RUNTIME {"method":"Runtime.getIsolateId","id":100000004}
workerd/util/symbolizer.c++:96: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=<path>`.
workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = Hostname mismatch
stack: 100f96c83 100f972b7 1022c433f 100f9ebe8 1022eebb8 1022ef000 1010b7a9b 1010b838b 1010b9a87 10109719c 10109dd44 1010b3f20 10028b8cc 10083cbdc; sentryErrorContext = jsgInternalError
workerd/io/worker.c++:1764: info: uncaught exception; source = Uncaught (in promise); exception = Error: internal error
workerd/io/io-context.c++:359: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg/workerd/jsg/value.h:1334: failed: jsg.Error: internal error
stack: 1008bd45c 1008be23b 1022c433f 10078df1c 10078e4dc
workerd/io/worker.c++:1764: info: uncaught exception; source = Uncaught (in promise); exception = Error: internal error
workerd/io/io-context.c++:359: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg/workerd/jsg/value.h:1334: failed: jsg.Error: internal error
stack: 1008bd45c 1008be23b 1022c433f 10078df1c 10078e4dc
โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }
petebacondarwin commented 7 months ago

I think this is a duplicate of #4562, which may be fixed by #4867. Please can you try out the pre-release version on that PR to see if you problem is resolved? Let's keep the discussion of this error on that other issue, unless we can tell this is a clear different problem. Closing this for now. We can reopen if it is not a duplicate.

lnewson commented 7 months ago

@petebacondarwin the pre-release from #4562 made no difference, the error still occurs 100% of the time whenever trying to view any page. I don't believe it is the same, as that is a different error message, talks about it occurring with DO's and happens when reloading. In this case we cannot even get a page to ever render it always just shows the internal error.

To add some more details, we don't have anything complex, it's just a pretty simple worker that fetches HTML pages from an Amazon S3 bucket.

Console output for reference:

$ npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7766885793/npm-package-wrangler-4867 dev --remote
Need to install the following packages:
https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7766885793/npm-package-wrangler-4867
Ok to proceed? (y) y
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
 โ›…๏ธ wrangler 0.0.0-fd900883
---------------------------
Running custom build: yarn build
yarn run v1.22.21
$ rollup -c rollup.config.js

src/main.ts โ†’ ./build/index.js...
created ./build/index.js in 497ms
โœจ  Done in 0.91s.
[wrangler:inf] Ready on http://localhost:8787
Total Upload: 89.31 KiB / gzip: 18.90 KiB
โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }

Edit: I realized a new pre-release build is available to tried with npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7792075553/npm-package-wrangler-4867 dev --remote as well. However, again it made no difference.

petebacondarwin commented 7 months ago

OK let's reopen this issue. It would be great if you were able to put together a small reproduction that we could debug. It will be quite hard to help without being able to reproduce it locally.

lnewson commented 7 months ago

@petebacondarwin I think I worked out how to replicate this, as I was having a lot of trouble replicating with a fresh setup. Even copying our worker code across to a new worker setup worked fine. However, one interesting thing about our setup is the worker name is dev_docs-prod. As soon as I use any name in wrangler.toml (even if the worker doesn't exist) that includes an underscore then I can reproduce this issue. It's also impossible, as far as I can tell, to create a worker nowadays with an underscore in the name.

For example, here was my worker and my wrangler.toml where I could reproduce using wrangler dev --remote and then opening the browser:

Worker (index.js):

export default {
  async fetch(request, env, ctx) {
    return new Response('Hello World!');
  },
};

wrangler.toml

name = "test_worker"
main = "./index.js"

account_id = "<ACCOUNT_ID>"
workers_dev = false

compatibility_date = "2022-09-01"
compatibility_flags = ["url_standard"]
petebacondarwin commented 6 months ago

Hmm. This is strange. I just ran wrangler dev --remote and wrangler deploy with a worker that has

name = "worker_app"

And it appears to be fine. I even had the same compat date and flags and workers_dev set to false.

petebacondarwin commented 6 months ago

What do you get when you try to deploy the worker that you have above? Can you share the debug logs?

petebacondarwin commented 6 months ago

Also are you able to debug and deploy workers that do not have underscores?

petebacondarwin commented 6 months ago

I wonder if there is something broken with your zone?

lnewson commented 6 months ago

So I created a brand new account on Cloudflare to make sure it's not our zone/account (as I can replicate on both our prod and test accounts). I was able to replicate the issue there as well. Here's the full steps I took:

  1. (Browser) Create new Cloudflare account and verify email
  2. (Terminal) Run npm create cloudflare@latest and answer as per this screenshot: image
  3. (Terminal) Change directory: cd test-worker
  4. (Terminal) Open wrangler.toml and rename the worker to test_worker.
  5. (Terminal) Deploy the worker npx wrangler deploy.
  6. (Terminal) Run wrangler dev remote npx wrangler dev --remote.
  7. (Terminal) Press b to open a browser and see the error occur in the terminal.
[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ npx wrangler deploy
 โ›…๏ธ wrangler 3.30.1
-------------------
Total Upload: 0.19 KiB / gzip: 0.16 KiB
Uploaded test_worker (1.33 sec)
Published test_worker (4.05 sec)
  https://test_worker.izack3333.workers.dev
Current Deployment ID: ba47e59b-42dc-4f3e-960a-37315b0e12f4
[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ npx wrangler dev --remote
 โ›…๏ธ wrangler 3.30.1
-------------------
[wrangler:inf] Ready on http://localhost:8787
Total Upload: 5.67 KiB / gzip: 1.73 KiB
โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }
lnewson commented 6 months ago

Re creating a worker with with an underscore in the name, it seems using deploy will create one (I did not expect that). Trying to create it via the UI or terminal from the start does not appear to work though: image

petebacondarwin commented 6 months ago

@lnewson - Thank you so much for putting the above together. I really appreciate the help here. ๐Ÿ˜ข - I just followed the steps above (except for creating a new account) and cannot recreate the error!

โžœ  temp npm create cloudflare@latest
Need to install the following packages:
create-cloudflare@2.13.0
Ok to proceed? (y) 

using create-cloudflare version 2.13.0

โ•ญ Create an application with Cloudflare Step 1 of 3
โ”‚ 
โ”œ In which directory do you want to create your application?
โ”‚ dir ./test-worker
โ”‚
โ”œ What type of application do you want to create?
โ”‚ type "Hello World" Worker
โ”‚
โ”œ Do you want to use TypeScript?
โ”‚ no typescript
โ”‚
โ”œ Copying template files 
โ”‚ files copied to project directory
โ”‚ 
โ”œ Updating name in `package.json` 
โ”‚ updated `package.json`
โ”‚ 
โ”œ Installing dependencies 
โ”‚ installed via `npm install`
โ”‚ 
โ•ฐ Application created 

โ•ญ Configuring your application for Cloudflare Step 2 of 3
โ”‚ 
โ”œ Retrieving current workerd compatibility date 
โ”‚ compatibility date 2024-02-23
โ”‚ 
โ”œ Do you want to use git for version control?
โ”‚ no git
โ”‚
โ•ฐ Application configured 

โ•ญ Deploy with Cloudflare Step 3 of 3
โ”‚ 
โ”œ Do you want to deploy your application?
โ”‚ no deploy via `npm run deploy`
โ”‚
โ”œ  APPLICATION CREATED  Deploy your application with npm run deploy
โ”‚ 
โ”‚ Navigate to the new directory cd test-worker
โ”‚ Run the development server npm run start
โ”‚ Deploy your application npm run deploy
โ”‚ Read the documentation https://developers.cloudflare.com/workers
โ”‚ Stuck? Join us at https://discord.gg/cloudflaredev
โ”‚ 
โ•ฐ See you again soon!

โžœ  temp cd test-worker 
โžœ  test-worker code .
โžœ  test-worker npx wrangler deploy
 โ›…๏ธ wrangler 3.30.1
 -------------------
Total Upload: 0.19 KiB / gzip: 0.16 KiB
Uploaded test_worker (3.66 sec)
Published test_worker (5.63 sec)
  https://test_worker.petebd.workers.dev
Current Deployment ID: a63eef52-e766-49bc-91b3-b59fbddcf5ea

โžœ  test-worker npx wrangler dev --remote
 โ›…๏ธ wrangler 3.30.1
-------------------
[wrangler:inf] Ready on http://localhost:8787
Total Upload: 5.68 KiB / gzip: 1.75 KiB
[wrangler:inf] GET / 200 OK (108ms)
[wrangler:inf] GET /favicon.ico 200 OK (50ms)
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ [b] open a browser, [d] open Devtools, [l] turn on local mode, [c] clear console, [x] to exit
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
petebacondarwin commented 6 months ago

Hmm, OK so I created a brand new account and now I see:

โžœ  test-worker npx wrangler dev --remote   
 โ›…๏ธ wrangler 3.30.1
-------------------
[wrangler:inf] Ready on http://localhost:8787
โœ˜ [ERROR] Could not create remote preview session on your account.

But equally I see that the workers.dev domain is still initialising...

Screenshot 2024-03-04 at 09 26 02
petebacondarwin commented 6 months ago

And once that completed (the initialization), it is working fine once again for me...

petebacondarwin commented 6 months ago

Looking back through your logs above I see:

workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = Hostname mismatch

I wonder if this is related?

petebacondarwin commented 6 months ago

I see on https://x509errors.org/ that the specific error you are getting there is documented as:

Explanation Information about the certificateโ€™s subject (an entity associated with the certificateโ€™s public key) is held in the subjectAltName extension or the subject field. However, the hostname of the server you are connecting to does not match the subject information in the certificate.

Security perspective You cannot verify the identity of the server to which you are connecting โ€“ you should not proceed. The server is either providing a wrong certificate (by being misconfigured) or is deliberately pretending to be a different entity to fool you. Sending or receiving data from unknown servers may put your systems at risk.

Next steps Compare the server hostname with the subjectAltName extension and the subject field of the certificate. Common misconfigurations include not including server aliases in the certificate (e.g., www.example.com for the server example.com).

petebacondarwin commented 6 months ago

Is there any chance you have a custom SSL certificate chain setup somehow?

lnewson commented 6 months ago

@petebacondarwin thanks for looking into this, it's a strange one. I've asked someone else to attempt to reproduce given these steps but they get the same error as me. I also tested with my personal macbook (running Sonoma 14.3.1) which doesn't have the same env as my work machine and still get the same error. I even tested using nix-shell in a pure env to try to reduce environmental factors (nix-shell --pure -p nodejs yarn).

As a test to double check, if I swap to redoing the steps without the rename to use the underscore then it all works as expected. If it was an SSL cert issue I'd expect it to fail regardless of the worker name ๐Ÿคท

Note: In case it matters, my work macbook is ARM based and my personal one is Intel based.

lnewson commented 6 months ago

@petebacondarwin if it helps to track down the issue, I found https://github.com/cloudflare/workers-sdk/issues/3264 which seemed to be similar to the error mentioned (granted that was for Windows not macOS). If I replicate that test in a Node REPL then I get the same error:

[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ node
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> const { Miniflare } = require('miniflare')
undefined
>   mf = new Miniflare({
...     modules: true,
...     script: `export default {
...       fetch() {
...         return fetch("https://test_worker.izack3333.workers.dev/");
...       }
...     }`,
...   });
Miniflare { dispatchFetch: [AsyncFunction: dispatchFetch] }
>   res = await mf.dispatchFetch("http://localhost");
workerd/util/symbolizer.c++:96: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=<path>`.
workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = Hostname mismatch
stack: 1035f818b 1035f87bf 104ab40ff 1035fffd4 104adecec 104adf134 10371ac7f 10371b6df 10371d0b7 1036fa414 103700fc0 1037170f0 10288f4d4 102e5bf58; sentryErrorContext = jsgInternalError
Response {
  [Symbol(realm)]: { settingsObject: {} },
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: false,
    requestIncludesCredentials: false,
    type: 'default',
    status: 500,
    timingInfo: null,
    cacheState: '',
    statusText: 'Internal Server Error',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [],
    body: { stream: undefined, source: null, length: null }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(2) { 'content-length' => [Object], 'content-type' => [Object] },
    [Symbol(headers map sorted)]: null
  },
  [Symbol(kWebSocket)]: null
}
> res.ok
false

whereas if I just change the fetch URL to the hyphen version instead of the underscore version it works as expected:

> const { Miniflare } = require('miniflare')
undefined
>   mf = new Miniflare({
...     modules: true,
...     script: `export default {
...       fetch() {
...         return fetch("https://test-worker.izack3333.workers.dev/");
...       }
...     }`,
...   });
Miniflare { dispatchFetch: [AsyncFunction: dispatchFetch] }
>   res = await mf.dispatchFetch("http://localhost");
Response {
  [Symbol(realm)]: { settingsObject: {} },
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: false,
    requestIncludesCredentials: false,
    type: 'default',
    status: 200,
    timingInfo: null,
    cacheState: '',
    statusText: 'OK',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [],
    body: { stream: undefined, source: null, length: null }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(8) {
      'alt-svc' => [Object],
      'cf-ray' => [Object],
      'content-length' => [Object],
      'content-type' => [Object],
      'date' => [Object],
      'nel' => [Object],
      'report-to' => [Object],
      'server' => [Object]
    },
    [Symbol(headers map sorted)]: null
  },
  [Symbol(kWebSocket)]: null
}
> res.ok
true
lnewson commented 6 months ago

I should also add if I do the fetch directly from the Node REPL it works:

[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ node
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> res = await fetch("https://test_worker.izack3333.workers.dev/")
Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: Proxy [
    {
      aborted: false,
      rangeRequested: false,
      timingAllowPassed: true,
      requestIncludesCredentials: true,
      type: 'default',
      status: 200,
      timingInfo: [Object],
      cacheState: '',
      statusText: 'OK',
      headersList: [HeadersList],
      urlList: [Array],
      body: [Object]
    },
    { get: [Function: get], set: [Function: set] }
  ],
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(10) {
      'date' => [Object],
      'content-type' => [Object],
      'content-length' => [Object],
      'connection' => [Object],
      'report-to' => [Object],
      'nel' => [Object],
      'vary' => [Object],
      'server' => [Object],
      'cf-ray' => [Object],
      'alt-svc' => [Object]
    },
    [Symbol(headers map sorted)]: null
  }
}
> res.ok
true
petebacondarwin commented 6 months ago

Yeah, I just can't reproduce that error. I am running a Mac M1, with the same OS version as you, and same node etc...

petebacondarwin commented 6 months ago

I wonder if this is related?

https://www.digicert.com/kb/ssl-support/underscores-not-allowed-in-fqdns.htm

petebacondarwin commented 6 months ago

And I am not able to reproduce because "I" am on an unusual network setup (i.e. Cloudflare's)?

lnewson commented 6 months ago

Maybe? I was also wondering if it was location based maybe (I'm in Australia). As an extra test, I also tried to replicate using a docker container (node:21) with an API token instead but wrangler dev --remote appears to work as expected there. What's interesting though, is if I try with the miniflare example above I do get the TLS error still.

Unrelated to the above, but as it does seem to be env specific, as a long shot I tried using node via NVM instead of homebrew, but the error still occurs. If it helps with env setup, here's more details on what I have installed via homebrew:

[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ node -e 'console.log(process.versions)'
{
  node: '20.11.1',
  acorn: '8.11.2',
  ada: '2.7.4',
  ares: '1.26.0',
  base64: '0.5.1',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '44.1',
  icu: '74.2',
  llhttp: '8.1.1',
  modules: '115',
  napi: '9',
  nghttp2: '1.59.0',
  openssl: '3.2.1',
  simdutf: '4.0.4',
  tz: '2023c',
  undici: '5.28.3',
  unicode: '15.1',
  uv: '1.48.0',
  uvwasi: '0.0.19',
  v8: '11.3.244.8-node.17',
  zlib: '1.2.13.1-motley-5daffc7'
}
[/tmp/test-worker] is ๐Ÿ“ฆ v0.0.0 โžœ openssl version
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)
petebacondarwin commented 6 months ago

I note these difference in my output for that command:

  nghttp2: '1.58.0',
  nghttp3: '0.7.0',
  ngtcp2: '0.8.1',
  openssl: '3.0.12+quic',
lnewson commented 6 months ago

I wonder if this is related?

https://www.digicert.com/kb/ssl-support/underscores-not-allowed-in-fqdns.htm

So I think you might be right here. I just don't know why it's not failing all the time though (is there some branch whereby the following doesn't run?).

Looking at what the workerd code does quickly, as best as I can atm, it uses capnproto which uses OpenSSL to verify the connection: https://github.com/capnproto/capnproto/blob/64802802df1d7780625eeb07b71d249fe49fb68d/c%2B%2B/src/kj/compat/tls.c%2B%2B#L218

Now, if I use the openssl CLI to verify the hostname I get a similar error:

openssl s_client -connect test_worker.izack3333.workers.dev:443 -verify_hostname test_worker.izack3333.workers.dev
...
---
SSL handshake has read 4476 bytes and written 421 bytes
Verification error: hostname mismatch

whereas when I use the hyphen version:

openssl s_client -connect test-worker.izack3333.workers.dev:443 -verify_hostname test-worker.izack3333.workers.dev
...
---
SSL handshake has read 4476 bytes and written 421 bytes
Verification: OK
Verified peername: *.izack3333.workers.dev
petebacondarwin commented 6 months ago

This fits on my side too... We use Cloudflare WARP to secure our Internet connection. When this is on, running the command from above I see:

Certificate chain
 0 s:CN=test_worker.izack3333.workers.dev
   i:C=US, ST=California, L=San Francisco, O=Cloudflare, Inc, CN=Cloudflare Corporate Zero Trust
   a:PKEY: id-ecPublicKey, 384 (bit); sigalg: ecdsa-with-SHA256
   v:NotBefore: Nov  2 13:42:16 2023 GMT; NotAfter: Aug 23 21:10:40 2024 GMT
 1 s:C=US, ST=California, L=San Francisco, O=Cloudflare, Inc, CN=Cloudflare Corporate Zero Trust
   i:C=US, ST=California, L=San Francisco, O=Cloudflare, Inc, CN=Cloudflare Corporate Zero Trust
   a:PKEY: id-ecPublicKey, 521 (bit); sigalg: ecdsa-with-SHA512
   v:NotBefore: Nov  2 13:42:16 2023 GMT; NotAfter: Oct 30 13:42:16 2033 GMT
...
SSL handshake has read 1694 bytes and written 421 bytes
Verification: OK
Verified peername: test_worker.izack3333.workers.dev

And when I turn it off:

Certificate chain
 0 s:CN=izack3333.workers.dev
   i:C=US, O=Let's Encrypt, CN=E1
   a:PKEY: id-ecPublicKey, 256 (bit); sigalg: ecdsa-with-SHA384
   v:NotBefore: Mar  3 22:55:43 2024 GMT; NotAfter: Jun  1 22:55:42 2024 GMT
 1 s:C=US, O=Let's Encrypt, CN=E1
   i:C=US, O=Internet Security Research Group, CN=ISRG Root X2
   a:PKEY: id-ecPublicKey, 384 (bit); sigalg: ecdsa-with-SHA384
   v:NotBefore: Sep  4 00:00:00 2020 GMT; NotAfter: Sep 15 16:00:00 2025 GMT
 2 s:C=US, O=Internet Security Research Group, CN=ISRG Root X2
   i:C=US, O=Internet Security Research Group, CN=ISRG Root X1
   a:PKEY: id-ecPublicKey, 384 (bit); sigalg: RSA-SHA256
   v:NotBefore: Sep  4 00:00:00 2020 GMT; NotAfter: Sep 15 16:00:00 2025 GMT
 3 s:C=US, O=Internet Security Research Group, CN=ISRG Root X1
   i:O=Digital Signature Trust Co., CN=DST Root CA X3
   a:PKEY: rsaEncryption, 4096 (bit); sigalg: RSA-SHA256
   v:NotBefore: Jan 20 19:14:03 2021 GMT; NotAfter: Sep 30 18:14:03 2024 GMT
...
SSL handshake has read 4476 bytes and written 421 bytes
Verification error: hostname mismatch

So I think that Cloudflare's SSL providers are more lenient?

petebacondarwin commented 6 months ago

This seems to have come up before: https://community.cloudflare.com/t/cant-put-underscore-in-workers-custom-domain/483048

petebacondarwin commented 6 months ago

And I even mention it here! https://github.com/cloudflare/workers-sdk/issues/833#issuecomment-1127496133

petebacondarwin commented 6 months ago

So given our investigations, I think that this is basically working as expected(?) I guess the follow ups could be:

petebacondarwin commented 6 months ago

https://github.com/cloudflare/workers-sdk/issues/5223 and https://github.com/cloudflare/cloudflare-docs/issues/13355.

Closing this and tracking there.

lnewson commented 6 months ago

Sorry have been away. Yeah that sounds about right, thanks! The 3.19.0 release is still somewhat of a breaking change for some edge case users such as myself, but we'll have to live with using 3.18.0 until we can safely replace the worker name to remove the underscore ๐Ÿ‘

zehawki commented 6 months ago

Phew, I also hit this issue. Suddenly started facing an error with wrangler dev with --remote (ie turn off local mode). Any POST to the worker results in:

503 Service Unavailable. Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.

Any browser open results in

โœ˜ [ERROR] Error in ProxyController: Error inside ProxyWorker

   {
    name: 'Error',
    message: 'internal error',
    stack: 'Error: internal error'
  }

Whereas everything is just fine and working as expected in local.

This was a worker than has been extensively tested with --remote earlier. And sometime in between the last testing to now, Ive upgraded wrangler to 3.29, and prolly I was < 3.18 earlier.

Now I understand it may be due to my worker name which is indeed using (_).

Question - What is the impact of changing the underscore to dash - thats essentially a renaming of the worker - and deploying? Will it create a NEW worker on a new path, or will it seamlessly replace the earlier one and everything continues working as before?

petebacondarwin commented 6 months ago

If you rename the worker by simply renaming it in wrangler.toml it will create a new Worker, leaving the old one behind. Instead you can rename the Worker in the CF dashboard.

I had a worker called test_worker, which I managed to create using Wrangler (the CF dashboard does not allow this). I logged in the dashboard, clicked on the Worker -> Manage -> Rename Worker. This allowed me to rename the Worker (the CF dashboard would not allow me to put an underscore in the name).

Note that the workers.dev subdomain will change accordingly, in case you rely upon this.

Screenshot 2024-03-24 at 16 18 51

Note the warning that is given:

Screenshot 2024-03-24 at 16 19 01

Now I would need to go and update the wrangler.toml with the new name so that next time I deploy from Wrangler it does not recreate the old Worker with the underscore in its name.

zehawki commented 6 months ago

Thank you for the detailed reply.

If you rename the worker by simply renaming it in wrangler.toml it will create a new Worker, leaving the old one behind.

For future reference, there is no data loss in this method right? Since the bindings remain the same. Its just that the new worker is on a new route - ALL else remains the same. I just have to switch my custom route to the new worker, and I'm done.