Illegal invocation error calling gadget API from cloudflare worker
I wonder if anyone else has run into this. We are trying to use our Gadget client from a Cloudflare worker, and we are getting
To isolate the problem, I ran the following in a standalone script:
…and it works as expected.
But then copy that same code into a fetch handler in a Cloudflare worker, and it's having trouble.
I wonder if anyone has run into this? Is this a known compatibility issue with the Cloudflare runtime? Any idea if there is a workaround?
6 Replies
hey Adam do you have a stack trace for the error? do you know which function is getting called with the wrong
this?Here's what I am seeing. looks like a mix of otel instrumentation, urql, and GadgetConnection
note: just a regular fetch to the graphql endpoint works fine, so that's been my temporary workaround.
@[Gadget] Harry I think for the time being we can close this. I am going to end up killing Axiom (a) because I cannot get it wired up with gadget (wink) and (b) because of this bug. If I just use Sentry for logs/traces and remove the open telemetry code, this problem goes away, and I don't need the graphql workaround. For now I think that's what we'll do. Could be useful as a thought exercise if this comes up again, but for us it's all good. We can just kill otel/axiom to keep trucking.
hi @Adam Neary -- we actually just shipped a change late yesterday to try to improve this situation! interally, we used to bind the fetch function, but we stopped doing that now! if you do something to cause your client to issue a new version, and then install that new version into your cloudflare worker package, you may find its fixed!
we used to do something like this:
which worked everywhere for years until you reported this issue, but now we do this:
Awesome. Thanks for following up on this. Sounds like a cleaner implementation. Good stuff!
Do you like this answer?