stripe-samples / stripe-node-cloudflare-worker-template

Use stripe-node in a Cloudflare Worker.
MIT License
77 stars 16 forks source link

docs: add Troubleshooting section on the README.md about the Miniflar… #13

Closed hideokamoto-stripe closed 3 months ago

hideokamoto-stripe commented 3 months ago

When starting the demo application, I encountered the following error.

$ npm run dev

> project-name@1.0.0 dev
> wrangler dev src/index.js

 ⛅️ wrangler 3.57.1
-------------------
Using vars defined in .dev.vars
Your worker has access to the following bindings:
- Vars:
  - STRIPE_API_KEY: "(hidden)"
  - WRANGLER_LOG: "(hidden)"
⎔ Starting local server...
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                                                                                      │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
/Users/hideokamoto/stripe/sandbox/javascript/hono/stripe-node-cloudflare-worker-template/node_modules/wrangler/wrangler-dist/cli.js:29749
            throw a;
            ^

MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
    at #assembleAndUpdateConfig (/Users/hideokamoto/stripe/sandbox/javascript/hono/stripe-node-cloudflare-worker-template/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:9111:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async #setOptions (/Users/hideokamoto/stripe/sandbox/javascript/hono/stripe-node-cloudflare-worker-template/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:9234:5)
    at async Mutex.runWith (/Users/hideokamoto/stripe/sandbox/javascript/hono/stripe-node-cloudflare-worker-template/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:3504:16) {
  code: 'ERR_RUNTIME_FAILURE',
  cause: undefined
}

Node.js v21.5.0

It took me some time to resolve the issue, so I created a pull request to add the solution to the README.md to help other developers. Since it involved changing the /etc/hosts file, Stripe employees might be particularly prone to encountering this issue.