From 5a38f420d8527d8bdb21e9974c809a3e98a6fbd1 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Fri, 14 Jun 2024 14:44:17 +0200 Subject: [PATCH] fix(core): Fix memory leak cause by unbounded array growth This `this.relations` array was accidentally being mutated with `.push()`, and thus growing unbounded on each call --- packages/core/src/service/services/product.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/service/services/product.service.ts b/packages/core/src/service/services/product.service.ts index adc5d4f922..47e17b5018 100644 --- a/packages/core/src/service/services/product.service.ts +++ b/packages/core/src/service/services/product.service.ts @@ -75,7 +75,7 @@ export class ProductService { options?: ListQueryOptions, relations?: RelationPaths, ): Promise>> { - const effectiveRelations = relations || this.relations; + const effectiveRelations = relations || this.relations.slice(); const customPropertyMap: { [name: string]: string } = {}; const hasFacetValueIdFilter = this.listQueryBuilder.filterObjectHasProperty( options?.filter, @@ -118,7 +118,7 @@ export class ProductService { productId: ID, relations?: RelationPaths, ): Promise | undefined> { - const effectiveRelations = relations ?? this.relations; + const effectiveRelations = relations ?? this.relations.slice(); if (relations && effectiveRelations.includes('facetValues')) { // We need the facet to determine with the FacetValues are public // when serving via the Shop API.