evanderkoogh / otel-cf-workers

An OpenTelemetry compatible library for instrumenting and exporting traces for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
210 stars 40 forks source link

[Bug] Wrangler 2 TypeError: defaults?.fetch?.bind is not a function #6

Closed AdiRishi closed 1 year ago

AdiRishi commented 1 year ago

Minimal recreation repository - https://github.com/AdiRishi/worker-wrangler2-otel-test

Steps to recreate

  1. Clone the repository
  2. Run yarn install
  3. Run yarn dev , the error should be visible in the console

Package Versions

Error

[mf:err] TypeError: defaults?.fetch?.bind is not a function
    at Miniflare.#reload (/Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/@miniflare/core/src/index.ts:810:48)
    at Miniflare.getPlugins (/Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/@miniflare/core/src/index.ts:1033:5)
    at createServer (/Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/@miniflare/http-server/src/index.ts:362:19)
    at startServer (/Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/@miniflare/http-server/src/index.ts:469:18)
    at main (file:///Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/wrangler/miniflare-dist/index.mjs:6374:22)
    at file:///Users/arishi/playground/cloudflare/worker-wrangler2-otel-test/node_modules/wrangler/miniflare-dist/index.mjs:6442:1
evanderkoogh commented 1 year ago

Again I can't stress how awesome it is to have repositories that reproduce the errors.. thanks so much for that..

And after a bit of trying to debug the wrong fetch function, I finally figured it out and have pushed a fix to the new 1.0.0.alpha.3 release. This is a bit of a rewrite of the current stable code with some breaking changes from 0.9.1.

I am expecting to move from alpha to rc in the next few days though, once it has seen a bit of traffic.