From 1670003956d504a3a96138dadafe1de7c3f1828b Mon Sep 17 00:00:00 2001 From: Lewis Clayton Date: Wed, 8 Oct 2025 11:27:17 +0100 Subject: [PATCH 1/2] memory test for beta --- src/customer.ts | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/customer.ts b/src/customer.ts index 1d484126..5e8882cf 100644 --- a/src/customer.ts +++ b/src/customer.ts @@ -494,29 +494,42 @@ export class Customer extends ServiceFactory { packValues: true, packKeys: true, }); + const streamArrayInstance = streamArray(); - const pipeline = chain([stream, parser, streamArray()]); + const pipeline = chain([stream, parser, streamArrayInstance]); let count = 0; - for await (const data of pipeline) { - const results = - data.value.results ?? - (data.value.summaryRow ? [data.value.summaryRow] : undefined) ?? - []; + try { + for await (const data of pipeline) { + const results = + data.value.results ?? + (data.value.summaryRow ? [data.value.summaryRow] : undefined) ?? + []; + + count += results.length; + if ( + this.clientOptions.max_reporting_rows && + count > this.clientOptions.max_reporting_rows && + !this.gaqlQueryStringIncludesLimit(gaqlQuery) + ) { + throw this.generateTooManyRowsError(); + } - count += results.length; - if ( - this.clientOptions.max_reporting_rows && - count > this.clientOptions.max_reporting_rows && - !this.gaqlQueryStringIncludesLimit(gaqlQuery) - ) { - throw this.generateTooManyRowsError(); - } + for (const row of results) { + const parsed = this.decamelizeKeysIfNeeded(row); + yield parsed as T; + } - for (const row of results) { - const parsed = this.decamelizeKeysIfNeeded(row); - yield parsed as T; + // Clear references to help GC + data.value = null; + data.key = null; } + } finally { + // Always destroy all components to prevent memory leaks + pipeline.destroy(); + parser.destroy(); + streamArrayInstance.destroy(); + stream.destroy(); } return; From 172cff37802975dd4f3a6a4aef97d0e872189217 Mon Sep 17 00:00:00 2001 From: Lewis Clayton Date: Wed, 8 Oct 2025 13:27:56 +0100 Subject: [PATCH 2/2] package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ddfd06a5..83ed5930 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "google-ads-api", - "version": "21.0.1", + "version": "21.0.2-beta.1", "description": "Google Ads API Client Library for Node.js", "repository": "https://github.com/Opteo/google-ads-api", "main": "build/src/index.js",