From 04b0c1614da7ec84d9c5a6dc20cbb8040adbe30a Mon Sep 17 00:00:00 2001 From: Yazeed Loonat Date: Thu, 8 Feb 2024 13:22:24 -0700 Subject: [PATCH] fix: fixing the cache purge (#3878) --- api/src/services/listing.service.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/api/src/services/listing.service.ts b/api/src/services/listing.service.ts index 4e950a34e0..2d31f831c8 100644 --- a/api/src/services/listing.service.ts +++ b/api/src/services/listing.service.ts @@ -1286,19 +1286,23 @@ export class ListingService implements OnModuleInit { this.httpService.request({ baseURL: process.env.PROXY_URL, method: 'PURGE', - url: shouldPurgeAllListings - ? '/listings?*' - : `/listings/${savedResponseId}*`, + url: `/listings/${savedResponseId}*`, }), undefined, ).catch((e) => - console.error( - shouldPurgeAllListings - ? 'purge all listings error = ' - : `purge listing ${savedResponseId} error = `, - e, - ), + console.error(`purge listing ${savedResponseId} error = `, e), ); + + if (shouldPurgeAllListings) { + await firstValueFrom( + this.httpService.request({ + baseURL: process.env.PROXY_URL, + method: 'PURGE', + url: '/listings?*', + }), + undefined, + ).catch((e) => console.error('purge all listings error = ', e)); + } } /*