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] Miniflare 3 Uncaught (async) RangeError: Maximum call stack size exceeded #5

Closed AdiRishi closed 1 year ago

AdiRishi commented 1 year ago

Minimal reproduction repository - https://github.com/AdiRishi/worker-wrangler3-otel-test

In order to produce the error, hit the / (root route).

Error - Uncaught (async) RangeError: Maximum call stack size exceeded

[mf:inf] Ready on http://127.0.0.1:8787/
[mf:inf] GET / 200 OK (18ms)
✘ [ERROR] Uncaught (in promise) RangeError: Maximum call stack size exceeded

  private _getContextManager(): ContextManager {
  ^
      at ContextAPI2._getContextManager
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@opentelemetry/api/src/api/context.ts:90:2)
      at ContextAPI2.active
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@opentelemetry/api/src/api/context.ts:60:16)
      at getActiveConfig
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/config.ts:117:24)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:133:24)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)
      at checkedFetch
  (/private/var/folders/__/f61lsp8x76551yjyz09hv0800000gp/T/tmp-40750-tWTIkkwORzHD/checked-fetch.js:22:19)
      at apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:19)
      at proxyHandler.apply
  (/Users/arishi/playground/cloudflare/worker-otel/node_modules/@microlabs/otel-cf-workers/src/instrumentation/common.ts:25:18)

✘ [ERROR] Uncaught (async) RangeError: Maximum call stack size exceeded
evanderkoogh commented 1 year ago

I think I have found the culprit, which is a function called checkedfetch in wrangler. They use the esbuild define to swap that out for the global fetch to wrap it and do some checks.

But I think it ends up with that function calling itself. I am not sure if it is something I can fix in this library or if I should fix it in wrangler, because this is probably an issue with any library that wants to proxy the native fetch function (not that many libraries would want to do that, but still)

AdiRishi commented 1 year ago

Ahh I see, so basically this piece of code gets messed up when the esbuild define swaps out the fetch function?

// src/instrumentation/fetch.ts
export function instrumentGlobalFetch(): void {
    globalThis.fetch = instrumentFetcher(fetch, (config) => config.globals.fetch)
}

Just a suggestion, I know this isn't ideal, but maybe this library should just export a custom fetch function like

import { instrumentedFetch as fetch } from '@microlabs/otel-cf-workers'

function test() {
    fetch() // this function is instrumented. And esbuild define won't replace it (maybe)
}

An approach like this might allow us to get around the issue you described? But again, I know the ideal DX would be for a developer to not have to think about this at all.

evanderkoogh commented 1 year ago

While we could certainly export a fetch function, I a) think that esbuild would still catch it as it is still a global fetch function and b) I absolutely wouldn't want to compromise our DX for a feature in wrangler that is there to catch obscure edge case errors only in development.

So the proper way forward is to fix this in wrangler, because we are just the first to want to proxy the global fetch function. But I will see if there is a work-around I can implement in this library in the meantime. But this would be an internal one only, not going to change the external interface because of it.

RichiCoder1 commented 1 year ago

@evanderkoogh I don't have a specific thought, but maybe you can do some sort of branding check w/ symbols to break the loop? Don't have a good specific suggestion though.

evanderkoogh commented 1 year ago

The proxy solution seems to work just fine in wrangler, just need to wrangle someone to merge it (see what I did there?!)

But I ran into an other issue about me being too smart for my own good (which happens a lot tbf). But that means the export was done in the inline request, which was killed after the returning of the response. So need to figure out the best way to deal with that. But that shouldn’t be too much of an issue.

evanderkoogh commented 1 year ago

Ok.. So all problems should be solved with 1.0.0-alpha.5 as soon as wrangler releases a new version with my PR in it: https://github.com/cloudflare/workers-sdk/pull/3497

AdiRishi commented 1 year ago

Hmmm @evanderkoogh I was testing 1.0.0-alpha.5 on wrangler 2 and saw this error whenever my worker included a fetch call.

[mf:err] GET /: TypeError: Cannot read properties of undefined (reading 'globals')

Screenshot 2023-06-21 at 11 31 33 am

Is this related to the issue we're seeing here in wrangler 3? Seems like it involves the global fetch function. Not sure if your PR will address this in wrangler 2. But maybe it doesn't need to if wrangler 2 is considered old now.

PS. This error can be seen in commit 88bf99c3373d135ab5a14e1a7861d06a15f2aa8a on the worker-wrangler2-otel-test repository.

AdiRishi commented 1 year ago

Also, I don't want to celebrate early or anything, but I just tested 1.0.0-alpha.5 against wrangler 3.1.1 and it's working!! :)

AdiRishi commented 1 year ago

Closing this issue. My latest test with 1.0.0-rc.2 passed and I'm running this with a worker in production.