kwhitley / itty-router

A little router.
MIT License
1.7k stars 77 forks source link

Upgrade from `4.0.9` to `4.0.10` then `wrangler dev --remote` fails #173

Closed chientrm closed 1 year ago

chientrm commented 1 year ago
✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/<my-cloudflare-account-id>/workers/scripts/youwave-worker/edge-preview) failed.

      at throwFetchError
  (/home/chientrm/youwave/worker/node_modules/wrangler/wrangler-dist/cli.js:121071:17)
      at fetchResult
  (/home/chientrm/youwave/worker/node_modules/wrangler/wrangler-dist/cli.js:121038:5)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async createPreviewToken
  (/home/chientrm/youwave/worker/node_modules/wrangler/wrangler-dist/cli.js:128483:29)
      at async createWorkerPreview
  (/home/chientrm/youwave/worker/node_modules/wrangler/wrangler-dist/cli.js:128504:17)
      at async start
  (/home/chientrm/youwave/worker/node_modules/wrangler/wrangler-dist/cli.js:147982:34) {
    text: 'A request to the Cloudflare API
  (/accounts/33fb3b5f3143369b69518f1e5f2ae750/workers/scripts/youwave-worker/edge-preview) failed.',
    notes: [
      {
        text: 'Uncaught ReferenceError: exports is not defined\n' +
          '  at index.js:418:5 in node_modules/itty-router/cjs/index.js\n' +
          '  at index.js:15:56 in __init\n' +
          '  at index.js:470:23 in node_modules/itty-router-extras/router/ThrowableRouter.js\n' +
          '  at index.js:18:52 in __require2\n' +
          '  at index.js:484:27 in node_modules/itty-router-extras/router/index.js\n' +
          '  at index.js:18:52 in __require2\n' +
          '  at index.js:513:75 in node_modules/itty-router-extras/index.js\n' +
          '  at index.js:18:52 in __require2\n' +
          '  at index.js:8402:41\n' +
          ' [code: 10021]'
      }
    ],
    location: undefined,
    kind: 'error',
    code: 10021
  }

Everything works fine with 4.0.9

kwhitley commented 1 year ago

Hey there! Could I see your package.json (or ideally, the whole repo)? Also what version of wrangler are you on? Mine doesn't even have the --remote flag...

Also a note, since I see the stack includes ThrowableRouter and itty-router-extras (which is now deprecated) in general, I'd recommend using the extras now in v4.x (see https://itty.dev/itty-router/migration-guide).

kwhitley commented 1 year ago

In the meantime, I've rolled out a reversal in 4.0.11, that for me at least... works in esm/module land, require/cjs land, etc.

kwhitley commented 1 year ago

@chientrm could you try itty-router@next and let me know if that works?

kwhitley commented 1 year ago

I've been running into similar issues with some configs in some projects... I'm attempting to revert to straight CJS for now (similar to v3.x), with an optional .mjs format for ES consumers.

chientrm commented 1 year ago

@chientrm could you try itty-router@next and let me know if that works?

Works as intended 💋

kwhitley commented 1 year ago

Yes! The change has been merged in and is live as 4.0.12 now :)