From 2198266457e283062ec849a70740b892b33f555e Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Wed, 20 Dec 2023 09:11:52 +0100 Subject: [PATCH] fix: better handling of when source isStable --- .../src/worker/accessorHandlers/http.ts | 20 ++++++------------- shared/packages/worker/src/worker/worker.ts | 11 +++------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/shared/packages/worker/src/worker/accessorHandlers/http.ts b/shared/packages/worker/src/worker/accessorHandlers/http.ts index 4c76d843..f42b1ede 100644 --- a/shared/packages/worker/src/worker/accessorHandlers/http.ts +++ b/shared/packages/worker/src/worker/accessorHandlers/http.ts @@ -97,18 +97,6 @@ export class HTTPAccessorHandle extends GenericAccessorHandle { - if (this.accessor.isStable) { - // We assume the it is stable, so we won't even check the headers: - return { - type: Expectation.Version.Type.HTTP_FILE, - - contentType: '', - contentLength: 0, - modified: 0, - etags: [`stable:${this.fullUrl}`], - } - } - const header = await this.fetchHeader() return this.convertHeadersToVersion(header.headers) @@ -259,7 +247,10 @@ export class HTTPAccessorHandle extends GenericAccessorHandle { @@ -281,7 +272,8 @@ export class HTTPAccessorHandle extends GenericAccessorHandle getData(url)) * */ - public async cacheTemporaryData( - accessorType: string, - key: string, - cb: () => Promise, - ttl = 1000 - ): Promise { + public async cacheData(accessorType: string, key: string, cb: () => Promise, ttl = 1000): Promise { // Check if data is in cache: if (!this._accessorTemporaryCache[accessorType]) this._accessorTemporaryCache[accessorType] = {} const cache = this._accessorTemporaryCache[accessorType] @@ -192,7 +187,7 @@ export abstract class GenericWorker { this._accessorTemporaryCacheCleanupTimeout = setTimeout(() => { this._accessorTemporaryCacheCleanupTimeout = undefined this._accessorTemporaryCacheCleanup() - }, ttl + 1) + }, 1000) } return data }