(
req: Request,
resOrPromise: Promise<Response> | Response,
lru: LruList,
okToCacheOpaque?: boolean,
)
| 468 | } |
| 469 | |
| 470 | private async safeCacheResponse( |
| 471 | req: Request, |
| 472 | resOrPromise: Promise<Response> | Response, |
| 473 | lru: LruList, |
| 474 | okToCacheOpaque?: boolean, |
| 475 | ): Promise<void> { |
| 476 | try { |
| 477 | const res = await resOrPromise; |
| 478 | try { |
| 479 | await this.cacheResponse(req, res, lru, okToCacheOpaque); |
| 480 | } catch (err) { |
| 481 | // Saving the API response failed. This could be a result of a full storage. |
| 482 | // Since this data is cached lazily and temporarily, continue serving clients as usual. |
| 483 | this.debugHandler.log( |
| 484 | err as Error, |
| 485 | `DataGroup(${this.config.name}@${this.config.version}).safeCacheResponse(${req.url}, status: ${res.status})`, |
| 486 | ); |
| 487 | |
| 488 | await this.detectStorageFull(); |
| 489 | } |
| 490 | } catch { |
| 491 | // Request failed |
| 492 | // TODO: Handle this error somehow? |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | private async loadFromCache( |
| 497 | req: Request, |
no test coverage detected