Skip to content

[REST Beta] customer.report() fails in Cloudflare Workers: "Response type 'stream' is not supported" #513

@StewartMedia

Description

@StewartMedia

When using the google-ads-api library (version 19.0.4-rest-beta) in a Cloudflare Workers environment, calls to customer.report() result in an Axios error: Google Ads Client Error: Response type 'stream' is not supported. This occurs despite customer.report() being part of the REST interface, which is expected to be more compatible with environments that do not support Node.js-style streams (like Cloudflare Workers).

To Reproduce Steps to reproduce the behavior:

  1. Set up a Cloudflare Worker project.
  2. Install google-ads-api@19.0.4-rest-beta.
  3. Initialize GoogleAdsApi and a Customer instance with valid OAuth credentials (client ID, client secret, refresh token, developer token) and a customer ID.
  4. Attempt to execute a report request using customer.report(reportOptions). Example reportOptions:
const reportRequest = {
  entity: "campaign" as fields.Resource, // Using type assertion as per strict types
  attributes: [
    "campaign.id" as fields.Attribute,
    "campaign.name" as fields.Attribute,
  ],
  order: [
    {
      field: "campaign.name" as fields.Attribute,
      sort_order: "ASC" as const,
    },
  ],
  limit: 5,
};
const results = await customer.report(reportRequest);
  1. The call fails with the aforementioned error.
    Expected behavior The customer.report() method in the REST-beta version of the library should successfully execute queries against the Google Ads API REST interface without attempting to use response types (like 'stream') that are incompatible with browser-like or Cloudflare Workers environments. The response should be a standard JSON payload.

Actual behavior The customer.report() call throws an AxiosError wrapped by the library:

{
  "error": {
    "code": 500,
    "message": "Google Ads Client Error: Response type 'stream' is not supported",
    "status": "CLIENT_LIBRARY_ERROR",
    "details": [
      {
        "errorCode": { "clientError": "AxiosError" },
        "message": "Response type 'stream' is not supported"
      }
    ]
  }
}

Environment:

google-ads-api version: 19.0.4-rest-beta
Node.js version: [Specify your local Node.js version, though the issue is in CF Workers runtime]
OS: [Specify your local OS, though the issue is in CF Workers runtime]
Runtime Environment: Cloudflare Workers
Additional context/attempts:

The issue was initially encountered with customer.query() and the switch to customer.report() was made specifically to leverage the REST interface, hoping to avoid stream-related problems.
Type assertions (as fields.Resource, as fields.Attribute) were necessary to satisfy TypeScript for ReportOptions due to strict type definitions in 19.0.4-rest-beta.
We investigated using the onQueryStart hook with editOptions to potentially modify the underlying Axios request options (e.g., to set responseType: 'json'). However, editOptions only accepts Partial which is based on the Google Ads API schema (services.ISearchGoogleAdsRequest) and does not seem to provide a passthrough for underlying HTTP client configurations like Axios's responseType.
This issue prevents the use of the google-ads-api (REST beta) for reporting in Cloudflare Workers. Any guidance on how to configure the underlying HTTP client or a fix from the library would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions