Skip to content

API bug when running in cloudflare workers #5

@ctusch

Description

@ctusch

I'm using the SDK in a cloudflare worker with nodejs_compat enabled. When I call an API via client it fails to send the request with the error:

ApiError: Illegal invocation: function called with incorrect `this` reference. See https://developers.cloudflare.com/workers/observability/errors/#illegal-invocation-errors for details.

The error originates here:

this.fetch = globalThis.fetch;

Binding the fetch to globalThis fixes it:

this.fetch = globalThis.fetch.bind(globalThis);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions