Skip to content

Commit

Permalink
fix(core): Fix memory leak cause by unbounded array growth
Browse files Browse the repository at this point in the history
This `this.relations` array was accidentally being mutated with
`.push()`, and thus growing unbounded on each call
  • Loading branch information
michaelbromley committed Jun 14, 2024
1 parent 623c5b4 commit 5a38f42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/service/services/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ProductService {
options?: ListQueryOptions<Product>,
relations?: RelationPaths<Product>,
): Promise<PaginatedList<Translated<Product>>> {
const effectiveRelations = relations || this.relations;
const effectiveRelations = relations || this.relations.slice();
const customPropertyMap: { [name: string]: string } = {};
const hasFacetValueIdFilter = this.listQueryBuilder.filterObjectHasProperty<ProductFilterParameter>(
options?.filter,
Expand Down Expand Up @@ -118,7 +118,7 @@ export class ProductService {
productId: ID,
relations?: RelationPaths<Product>,
): Promise<Translated<Product> | 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.
Expand Down

0 comments on commit 5a38f42

Please sign in to comment.