cloudflare / workers-sdk

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

๐Ÿ› BUG: Fatal error on installing latest Nuxt with new Worker #6933

Closed ManasMadrecha closed 2 days ago

ManasMadrecha commented 1 month ago

Which Cloudflare product(s) does this pertain to?

Workers Runtime

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

3.80.0 [Wrangler], 2.9.7 [Nitropack], 3.13.0 [Nuxt]

What version of Node are you using?

20.16.0

What operating system and version are you using?

Windows 11

Describe the Bug

Observed behavior

Error on starting a simple bare-bones app.

Expected behavior

It should start normally.

Steps to reproduce

Just follow the instruction on https://developers.cloudflare.com/workers/frameworks/framework-guides/nuxt

This fails.

Note that npm run build succeeds. But then, npx wrangler dev fails.

Code

Here is the auto-generated wrangler.toml

#:schema node_modules/wrangler/config-schema.json
name = "my-nuxt-app"
compatibility_date = "2024-10-04"
main = "./dist/worker/index.js"
assets = { directory = "./dist/public", binding = "ASSETS" }

# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
[observability]
enabled = true

Here is the auto-generated package-json

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "npm run build && wrangler dev",
    "postinstall": "nuxt prepare",
    "deploy": "npm run build && wrangler deploy",
    "cf-typegen": "wrangler types"
  },
  "dependencies": {
    "nuxt": "^3.13.0",
    "vue": "latest",
    "vue-router": "latest"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20241004.0",
    "nitro-cloudflare-dev": "^0.1.6",
    "nitropack": "^2.9.7",
    "wrangler": "^3.80.2"
  }
}

Please provide a link to a minimal reproduction

https://developers.cloudflare.com/workers/frameworks/framework-guides/nuxt

Please provide any relevant error logs

Error on npm run dev

Nuxt 3.13.2 with Nitro 2.9.7                                                                                                                              3:47:16 pm
                                                                                                                                                          3:47:16 pm
  โžœ Local:    http://localhost:3000/
  โžœ Network:  use --host to expose

  โžœ DevTools: press Shift + Alt + D in the browser (v1.5.2)                                                                                               3:47:20 pm

 โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚                                                         โ”‚
 โ”‚  ๐Ÿ”ฅ Cloudflare context bindings enabled for dev server  โ”‚
 โ”‚                                                         โ”‚
 โ”‚  Config path: wrangler.toml                             โ”‚
 โ”‚  Persist dir: .wrangler\state\v3                        โ”‚
 โ”‚                                                         โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โœ” Vite client built in 68ms                                                                                                                              3:47:23 pm
โœ” Vite server built in 1177ms                                                                                                                            3:47:24 pm
โœ” Nuxt Nitro server built in 1768 ms                                                                                                               nitro 3:47:26 pm
โ„น Vite client warmed up in 1ms                                                                                                                           3:47:26 pm   
โ„น Vite server warmed up in 1339ms                                                                                                                        3:47:28 pm

 ERROR  *** Received structured exception #0xc0000005: access violation; stack: 7ffd616e32f7 7ff75513587b 7ff755135943 7ff755128e3c 7ff755128de7 7ff754974e4e 7ff75497515f 7ff7537a1ee6 7ff754aefa9f 7ff754af6d36 7ff754aeffa3 7ff754af6d36 7ff754aed93c 7ff753791e61 7ff7562377ef 7ffdb20f257c 7ffdb356af07

 ERROR  Failed to initialize wrangler bindings proxy The Workers runtime failed to start. There is likely additional logging output above.

  at Miniflare2.#assembleAndUpdateConfig (node_modules\miniflare\src\index.ts:1395:10)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at Mutex.runWith (node_modules\miniflare\src\workers\shared\sync.ts:66:45)
  at Miniflare2.#waitForReady (node_modules\miniflare\src\index.ts:1477:3)
  at Miniflare2._getProxyClient (node_modules\miniflare\src\index.ts:1683:3)
  at Miniflare2.getBindings (node_modules\miniflare\src\index.ts:1706:23)
  at async getPlatformProxy (node_modules\wrangler\wrangler-dist\cli.js:217201:20)
  at _getPlatformProxy (node_modules\nitro-cloudflare-dev\dist\runtime\plugin.dev.mjs:41:17)

Error on npx wrangler dev after successfully running npm run build

npx wrangler dev

 โ›…๏ธ wrangler 3.80.2
-------------------

โ–ฒ [WARNING] The entrypoint dist\worker\index.js has exports like an ES Module, but hasn't defined a default export like a module worker normally would. Building the worker using "service-worker" format...

X [ERROR] There was an access violation in the runtime.

  On Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.
  Check that you have the latest version installed.
  See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.

โŽ” Starting local server...
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  [b] open a browser, [d] open devtools, [l] turn off local mode, [c] clear console, [x] to exit  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
C:\Users\manas\dev\PROJECT\cf-w-nuxt\node_modules\wrangler\wrangler-dist\cli.js:29768
            throw a;
            ^

MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
    at #assembleAndUpdateConfig (C:\Users\manas\dev\manasmoney\cf-w-nuxt\node_modules\miniflare\dist\src\index.js:9842:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Mutex.runWith (C:\Users\manas\dev\manasmoney\cf-w-nuxt\node_modules\miniflare\dist\src\index.js:3627:16) {
  code: 'ERR_RUNTIME_FAILURE',
  cause: undefined
}

Node.js v20.16.0
irvinebroque commented 1 month ago

Hmm don't think this is specific to Nuxt but this is a workerd exception on Windows.

See the error message shown when you hit the error:

On Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.
Check that you have the latest version installed.
See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.

Have you tried this?

ManasMadrecha commented 1 month ago

The Windows error might prop up on npx wrangler dev, but why is the first command of npm run dev itself showing an error that workerd unable to initialise worker bindings or so? ๐Ÿ˜ฏ

I've a Nuxt 3 app running on CF Pages nicely. But I wanted to try the new option available on running the framework on workers as well.

penalosa commented 2 days ago

@ManasMadrecha to clarify, have you tried updating the Microsoft Visual C++ Redistributable library? What version are you on?

ManasMadrecha commented 2 days ago

Yes, updated that and now it's working. ๐Ÿ˜ฏ Seemed like a pretty easy solution, but don't know why it was an issue in the first place ๐Ÿ™๐Ÿป