cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.41k stars 593 forks source link

🐛 BUG: Received structured exception #0xc0000005: access violation; #6170

Open asasinmode opened 6 days ago

asasinmode commented 6 days ago

Which Cloudflare product(s) does this pertain to?

Miniflare

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

3.20240620.0 [Miniflare]

What version of Node are you using?

22.3.0

What operating system and version are you using?

Windows 11 10.0.22631

Describe the Bug

Observed behavior

Starting dev server errors with (full logs attached with some additional console logs)

 ERROR  *** Received structured exception #0xc0000005: access violation; stack: 7ffe71872f57 7ff7834b643b 7ff7834b6503 7ff7834a588c 7ff7834a5837 7ff782ce9c1e 7ff782ce9f2f 7ff781bd1ad6 7ff781bd18ba 7ff782e6b6ef 7ff782e728a6 7ff782e6bc0c 7ff782e728a6 7ff782e6957c 7ff781bc1551 7ff7845a0f7f 7ffeb2a3257c 7ffeb3a4af27

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

Then nothing else happens, http://localhost:3000 shows nuxt login page and I stop the process

Expected behavior

No error

Steps to reproduce

  1. Initialize a Nuxt Hub project with pnpx nuxthub init tmp
  2. Go the the created project cd tmp
  3. Start the dev server pnpm dev

This is my first encounter with cloudflare ecosystem and it's through the Nuxt Hub project. Sorry but I don't know how to use cloudflare tools outside of it.

The wrangler.toml is generated inside .data/hub/wrangler.toml

[[r2_buckets]]
binding = "BLOB"
bucket_name = "default"

[[kv_namespaces]]
binding = "KV"
id = "kv_default"

[[d1_databases]]
binding = "DB"
database_name = "default"
database_id = "default"

I don't know of any worker code.

I'm guessing it's not reproducible to be honest. Initially I created a Nuxt Hub project in the same way and was working on it with no issues, everything worked fine. At some point in development however I was running into errors and while trying to resolve them I wanted to clean start my project and deleted various directories like .nuxt, .data and I think inside of a project there was a .wrangler directory that seemed to have one or 2 empty subdirectories. Additionally I deleted local pnpm store and I think anything related I could find in %localappdata% and %tmp% to clear cache in case that was causing the errors I was experiencing (nothing cloudflare related, just some type errors in packages). It fixed the errors I was experiencing but I think from then on running pnpm dev showed that error and now it happens in all fresh Nuxt Hub projects.

I'd appreciate guidance on how to deal with it. Tried my best to add logs to find out what's going on, here are the changes I made to node_modules\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\dist\src\index.js. Don't know how to access source files, hope they context is enough to identify them. In the logs you can see console.log("ch2", maybeSocketPorts); is never reached

// #assembleAndUpdateConfig method
    const loopbackAddress = `${maybeGetLocallyAccessibleHost(configuredHost) ?? getURLSafeHost(configuredHost)}:${loopbackPort}`;
    const runtimeOpts = {
      signal: this.#disposeController.signal,
      entryAddress,
      loopbackAddress,
      requiredSockets,
      inspectorAddress,
      verbose: this.#sharedOpts.core.verbose,
      handleRuntimeStdio: this.#sharedOpts.core.handleRuntimeStdio
    };
    console.log("ch0 running #runtime.updateConfig");  // HERE
    const maybeSocketPorts = await this.#runtime.updateConfig(
      configBuffer,
      runtimeOpts
    );
    console.log("ch1", maybeSocketPorts, { aborted: this.#disposeController.signal.aborted, isVoid0: maybeSocketPorts === void 0 });  // HERE
    if (this.#disposeController.signal.aborted)
      return;
    if (maybeSocketPorts === void 0) {
      throw new MiniflareCoreError(
        "ERR_RUNTIME_FAILURE",
        "The Workers runtime failed to start. There is likely additional logging output above."
      );
    }
    console.log("ch2", maybeSocketPorts);  // HERE, doesn't run
    this.#socketPorts = maybeSocketPorts;

// waitForPorts function
  try {
    console.log('waitForPorts try', lines);  // HERE
    for await (const line of lines) {
      console.log('waitForPorts trying', line);  // HERE, doesn't run
      const message = ControlMessageSchema.safeParse(JSON.parse(line));

// updateConfig method
    runtimeProcess.stdin.write(configBuffer);
    runtimeProcess.stdin.end();
    await (0, import_events2.once)(runtimeProcess.stdin, "finish");
    console.log('updateConfig return');  // HERE
    return waitForPorts(controlPipe, options);

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

> nuxthub-starter@ dev D:\Projects\tmp
> nuxt dev

Nuxt 3.12.2 with Nitro 2.9.7                                                                                                                        12:19:43
                                                                                                                                                    12:19:43
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Using local storage from .data/hub                                                                                                      nuxt:hub 12:19:45
  ➜ DevTools: press Shift + Alt + D in the browser (v1.3.7)                                                                                         12:19:45

ℹ Running with compatibility version 4                                                                                                             12:19:45
ℹ Vite client warmed up in 971ms                                                                                                                   12:19:47
ℹ Vite server warmed up in 1081ms                                                                                                                  12:19:47
✔ Nuxt Nitro server built in 828 ms                                                                                                          nitro 12:19:48
ch0 running #runtime.updateConfig
updateConfig return
waitForPorts try Interface {
  isCompletionEnabled: true,
  escapeCodeTimeout: 500,
  tabSize: 8,
  _events:
   [Object: null prototype] {
     close:
      { [Function: bound onceWrapper] listener: [Function: onSelfCloseWithoutTerminal] } },
  _eventsCount: 1,
  _maxListeners: undefined,
  line: '',
  output: undefined,
  input:
   <ref *1> Socket {
     connecting: false,
     _hadError: false,
     _parent: null,
     _host: null,
     _closeAfterHandlingError: false,
     _events:
      { close: [Function (anonymous)],
        error: [Function: onerror],
        prefinish: undefined,
        finish: undefined,
        drain: undefined,
        data: [Function: ondata],
        end: [Array],
        readable: undefined },
     _readableState:
      ReadableState {
        highWaterMark: 16384,
        buffer: [],
        bufferIndex: 0,
        length: 0,
        pipes: [],
        awaitDrainWriters: null,
        [Symbol(kState)]: 194062596 },
     _writableState:
      WritableState {
        highWaterMark: 16384,
        length: 0,
        corked: 0,
        onwrite: [Function: bound onwrite],
        writelen: 0,
        bufferedIndex: 0,
        pendingcb: 0,
        [Symbol(kState)]: 17564420,
        [Symbol(kBufferedValue)]: null },
     allowHalfOpen: false,
     _maxListeners: undefined,
     _eventsCount: 4,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: null,
     _server: null,
     [Symbol(async_id_symbol)]: 644,
     [Symbol(kHandle)]:
      Pipe {
        reading: true,
        [Symbol(kResourceStore)]: undefined,
        [Symbol(owner_symbol)]: [Circular *1] },
     [Symbol(lastWriteQueueSize)]: 0,
     [Symbol(timeout)]: null,
     [Symbol(kBuffer)]: null,
     [Symbol(kBufferCb)]: null,
     [Symbol(kBufferGen)]: null,
     [Symbol(shapeMode)]: true,
     [Symbol(kCapture)]: false,
     [Symbol(kSetNoDelay)]: false,
     [Symbol(kSetKeepAlive)]: false,
     [Symbol(kSetKeepAliveInitialDelay)]: 0,
     [Symbol(kBytesRead)]: 0,
     [Symbol(kBytesWritten)]: 0 },
  history: [],
  historySize: 30,
  removeHistoryDuplicates: false,
  crlfDelay: 100,
  completer: undefined,
  terminal: false,
  [Symbol(_sawReturnAt)]: 0,
  [Symbol(_sawKeyPress)]: false,
  [Symbol(_previousKey)]: null,
  [Symbol(shapeMode)]: false,
  [Symbol(kCapture)]: false,
  [Symbol(kSubstringSearch)]: null,
  [Symbol(_undoStack)]: [],
  [Symbol(_redoStack)]: [],
  [Symbol(_killRing)]: [],
  [Symbol(_killRingCursor)]: 0,
  [Symbol(_prompt)]: '> ',
  [Symbol(line object stream)]: undefined,
  [Symbol(_decoder)]:
   StringDecoder { encoding: 'utf8', [Symbol(kNativeDecoder)]: <Buffer 00 00 00 00 00 00 01> } }

 ERROR  *** Received structured exception #0xc0000005: access violation; stack: 7ffe71872f57 7ff7834b643b 7ff7834b6503 7ff7834a588c 7ff7834a5837 7ff782ce9c1e 7ff782ce9f2f 7ff781bd1ad6 7ff781bd18ba 7ff782e6b6ef 7ff782e728a6 7ff782e6bc0c 7ff782e728a6 7ff782e6957c 7ff781bc1551 7ff7845a0f7f 7ffeb2a3257c 7ffeb3a4af27

ch1 undefined { aborted: false, isVoid0: true }

 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\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\src\index.ts:1352:8)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at Mutex.runWith (node_modules\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\src\workers\shared\sync.ts:66:45)
  at Miniflare2.#waitForReady (node_modules\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\src\index.ts:1443:3)
  at Miniflare2._getProxyClient (node_modules\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\src\index.ts:1638:4)
  at Miniflare2.getBindings (node_modules\.pnpm\miniflare@3.20240620.0\node_modules\miniflare\src\index.ts:1666:22)
  at getPlatformProxy (node_modules\.pnpm\wrangler@3.62.0_@cloudflare+workers-types@4.20240620.0\node_modules\wrangler\src\api\integrations\platform\index.ts:117:24)
  at _getPlatformProxy (node_modules\.pnpm\nitro-cloudflare-dev@0.1.4\node_modules\nitro-cloudflare-dev\dist\runtime\plugin.dev.mjs:41:17)
  at <anonymous> (node_modules\.pnpm\@nuxthub+core@0.7.0_ioredis@5.4.1_magicast@0.3.4_rollup@4.18.0_vite@5.3.2_@types+node@20.14.9_terser@5.31.1_\node_modules\@nuxthub\core\dist\runtime\ready.dev.js:4:3)
es-ki commented 5 days ago

Same. I’m using Windows 11 with SvelteKit.

It works fine on Windows 10.

Nima52 commented 4 days ago

I seem to be encountering the same issue as the OP. I was working on an old project, and when I updated it and ran it (3.61.0 works, higher than that it breaks), I encountered a similar issue. So, I created a new project using “npx create-cloudflare@latest” and made a “hello world js” project. Here is what I got from the logs:

--- 2024-06-30T19:28:07.425Z debug
🪵  Writing logs to "C:\Users\...\.wrangler\logs\wrangler-2024-06-30_19-28-07_302.log"
---

--- 2024-06-30T19:28:07.425Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Cycles of Seasons\100 - Virtues\110 - Demiourgia\test-wrangler\hello-world-js\.env'
    at Object.openSync (node:fs:573:18)
    at Object.readFileSync (node:fs:452:35)
    at tryLoadDotEnv (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:158768:72)
    at loadDotEnv (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:158777:12)
    at C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:202740:20
    at C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:162911:16
    at maybeAsyncResult (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:161132:44)
    at C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:162910:14
    at C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:161119:22
    at Array.reduce (<anonymous>) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\...\\test-wrangler\\hello-world-js\\.env'
}
---

--- 2024-06-30T19:28:07.432Z log

 ⛅️ wrangler 3.62.0
[38;2;255;136;0m-------------------[39m

---

--- 2024-06-30T19:28:07.450Z debug
Metrics dispatcher: Posting data {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":false}}
---

--- 2024-06-30T19:28:07.455Z debug
Failed to load .env file "C:\...\test-wrangler\hello-world-js\.dev.vars": Error: ENOENT: no such file or directory, open 'C:\...\test-wrangler\hello-world-js\.dev.vars'
    at Object.openSync (node:fs:573:18)
    at Object.readFileSync (node:fs:452:35)
    at tryLoadDotEnv (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:158768:72)
    at loadDotEnv (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:158777:12)
    at getVarsForDev (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:200152:18)
    at getBindings (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:207740:10)
    at getBindingsAndAssetPaths (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:207621:20)
    at getDevReactElement (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:207276:40)
    at startDev (C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:207343:60)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\...\\test-wrangler\\hello-world-js\\.dev.vars'
}
---

--- 2024-06-30T19:28:07.571Z log
[2m⎔ Starting local server...[22m
---

--- 2024-06-30T19:28:07.580Z debug
*** Received structured exception #0xc0000005: access violation; stack: 7ffcf4ed2f57 7ff7e9e1643b 7ff7e9e16503 7ff7e9e0588c 7ff7e9e05837 7ff7e9649c1e 7ff7e9649f2f 7ff7e8531ad6 7ff7e85318ba 7ff7e97cb6ef 7ff7e97d28a6 7ff7e97cbc0c 7ff7e97d28a6 7ff7e97c957c 7ff7e8521551 7ff7eaf00f7f 7ffd07c2257c 7ffd0824af27
---

--- 2024-06-30T19:28:07.632Z debug
*** Received structured exception #0xc0000005: access violation; stack: 7ffcf4ed2f57 7ff7e9e1643b 7ff7e9e16503 7ff7e9e0588c 7ff7e9e05837 7ff7e9649c1e 7ff7e9649f2f 7ff7e8531ad6 7ff7e85318ba 7ff7e97cb6ef 7ff7e97d28a6 7ff7e97cbc0c 7ff7e97d28a6 7ff7e97c957c 7ff7e8521551 7ff7eaf00f7f 7ffd07c2257c 7ffd0824af27
---

When starting the server:

C:\...\test-wrangler\hello-world-js\node_modules\wrangler\wrangler-dist\cli.js:29747
            throw a;
            ^

MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
    at #assembleAndUpdateConfig (C:\...\test-wrangler\hello-world-js\node_modules\miniflare\dist\src\index.js:9161:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Mutex.runWith (C:\...\test-wrangler\hello-world-js\node_modules\miniflare\dist\src\index.js:3521:16) {
  code: 'ERR_RUNTIME_FAILURE',
  cause: undefined
}

I have the same specifications as the OP: Edition Windows 11 Pro OS Version 10.0.22631

And i was also able to replicate OP’s issue:

ERROR  *** Received structured exception #0xc0000005: access violation; stack: 7ffcf4ed2f57 7ff7ce37643b 7ff7ce376503 7ff7ce36588c 7ff7ce365837 7ff7cdba9c1e 7ff7cdba9f2f 7ff7cca91ad6 7ff7cca918ba 7ff7cdd2b6ef 7ff7cdd328a6 7ff7cdd2bc0c 7ff7cdd328a6 7ff7cdd2957c 7ff7cca81551 7ff7cf460f7f 7ffd07c2257c 7ffd0824af27

The addresses I get from the OP’s issue are the same when replicating it. But the one for the hello-world-js is slightly different. Here is a side by side comparison:

Hello-world-js stack:

7ffcf4ed2f57 7ff7e9e1643b 7ff7e9e16503 7ff7e9e0588c 7ff7e9e05837 7ff7e9649c1e 7ff7e9649f2f 7ff7e8531ad6 7ff7e85318ba 7ff7e97cb6ef 7ff7e97d28a6 7ff7e97cbc0c 7ff7e97d28a6 7ff7e97c957c 7ff7e8521551 7ff7eaf00f7f 7ffd07c2257c 7ffd0824af27

OP stack:

7ffcf4ed2f57 7ff7ce37643b 7ff7ce376503 7ff7ce36588c 7ff7ce365837 7ff7cdba9c1e 7ff7cdba9f2f 7ff7cca91ad6 7ff7cca918ba 7ff7cdd2b6ef 7ff7cdd328a6 7ff7cdd2bc0c 7ff7cdd328a6 7ff7cdd2957c 7ff7cca81551 7ff7cf460f7f 7ffd07c2257c 7ffd0824af27
petebacondarwin commented 3 days ago

It sounds like the recent bump to workerd (that happened at Wrangler 3.62.0) might have introduced a regression that only affects Windows 11? (Our local Windows environments are currently only Windows 10; and our CI is running on Windows Server 2022). We are looking to get a Windows 11 install up and running to test this.