Closed eddyerburgh closed 5 years ago
3.4.0
timeout
ignoreCacheErrors
true
Cache should timeout and return response
Cache times out and doesn't return response
getFromCache
storeInCache
async function example() { class mockCatbox { isReady() { return true; } get() { return new Promise(() => {}); } set() { return new Promise(() => { // setTimeout to keep node process running setTimeout(() => {}, 60000) }); } } const cache = require('@bbc/http-transport-cache'); const HttpTransport = require('@bbc/http-transport'); const mcb = new mockCatbox(); const url = 'https://ibl.api.bbc.co.uk/ibl/v1/episodes/p0740k63?rights=web&availability=available&mixin=live'; const client = HttpTransport.createBuilder() .use(cache.maxAge(mcb, {timeout: 2000, ignoreCacheErrors: true})) .use(cache.staleIfError(mcb)) .createClient(); const body = await client.get(url) .asBody(); console.log(body); } example();
Version
3.4.0
Steps to reproduce
timeout
andignoreCacheErrors
true
in maxAge middlewareWhat is expected?
Cache should timeout and return response
What is actually happening?
Cache times out and doesn't return response
getFromCache
times out as expected (see code)storeInCache
which doesn’t have a timeout applied (see code)Reproduction