Open buildbreaker opened 2 months ago
I'm using dd-api-client on frontend with a proxy to my backend to proxy the requests.
When updating to 1.26.0 I started receiving this error on the frontend
An error occurred during the HTTP request: TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
I feel like this error is related to the one reported on this issue
I have been running into the same issues on CF pages functions. I passed in a custom http client (fetch as an option didn't work) with .bind
as per the help page, and it seems to be working.
// I'm not sure if this is the best way to import this...
import { IsomorphicFetchHttpLibrary } from '@datadog/datadog-api-client/dist/packages/datadog-api-client-common'
import { client } from '@datadog/datadog-api-client'
...
const httpApi = new IsomorphicFetchHttpLibrary({ fetch: fetch.bind(this) })
const config = client.createConfiguration({ httpApi })
const apiInstance = new v2.LogsApi(config)
...
Describe the bug I'm currently using the datadog api client within my cloudflare worker and I recently updated the client from version 1.24 to 1.27. I ran into this error since the update:
I took a look at the changes across the different versions and found this PR: https://github.com/DataDog/datadog-api-client-typescript/pull/1646
It looks like that might be that change that caused the error I started observing. I was able to resolve my problem by downgrading back to 1.24.
To Reproduce Steps to reproduce the behavior: Try calling a datadog api client within a CF worker context. It's tail logs describe the error I shared. (I can provide a repo which can be used to test if that's desired)
Expected behavior I would like to expect that the latest datadog client continues to send requests in my cloudflare worker.
Screenshots n/a
Environment and Versions (please complete the following information): A clear and precise description of your setup:
version for this project in use. 1.27 (but it looks like any version that is 1.26 or later)
services, libraries, languages and tools list and versions. package.json:
Additional context I am guessing this has to do with the CF runtime releasing the
this
reference in the PR when the client attempts to make the fetch request call.cc @linnea-moment