@@ -220,60 +220,64 @@ test('timeout', async ({ expect }) => {
220
220
expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
221
221
} ) ;
222
222
223
- test ( 'run action again when the action expires' , async ( { expect } ) => {
224
- const ttlMs = 10 ;
225
- const redis = new Redis ( ) ;
226
- const prefix = randomString ( ) ;
227
- const pollIntervalMs = 5 ;
228
- const timeoutMs = 50 ;
229
- const cacheForRequest1 = createCache ( {
230
- redis,
231
- logger : {
232
- debug : vi . fn ( ) as any ,
233
- warn : vi . fn ( ) as any ,
234
- } ,
235
- prefix,
236
- pollIntervalMs,
237
- timeoutMs,
238
- ttlMs : {
239
- success : ttlMs ,
240
- failure : ttlMs ,
241
- } ,
242
- } ) ;
243
-
244
- const cacheForRequest2 = createCache ( {
245
- redis,
246
- logger : {
247
- debug : vi . fn ( ) as any ,
248
- warn : vi . fn ( ) as any ,
249
- } ,
250
- prefix,
251
- pollIntervalMs,
252
- timeoutMs,
253
- ttlMs : {
254
- success : ttlMs ,
255
- failure : ttlMs ,
256
- } ,
257
- } ) ;
258
-
259
- const actionId = randomString ( ) ;
260
- async function actionFn ( ) {
261
- await waitFor ( timeoutMs - 1 ) ;
262
- return 'foo' ;
263
- }
223
+ test (
224
+ 'run action again when the action expires' ,
225
+ async ( { expect } ) => {
226
+ const ttlMs = 10 ;
227
+ const redis = new Redis ( ) ;
228
+ const prefix = randomString ( ) ;
229
+ const pollIntervalMs = 5 ;
230
+ const timeoutMs = 50 ;
231
+ const cacheForRequest1 = createCache ( {
232
+ redis,
233
+ logger : {
234
+ debug : vi . fn ( ) as any ,
235
+ warn : vi . fn ( ) as any ,
236
+ } ,
237
+ prefix,
238
+ pollIntervalMs,
239
+ timeoutMs,
240
+ ttlMs : {
241
+ success : ttlMs ,
242
+ failure : ttlMs ,
243
+ } ,
244
+ } ) ;
245
+
246
+ const cacheForRequest2 = createCache ( {
247
+ redis,
248
+ logger : {
249
+ debug : vi . fn ( ) as any ,
250
+ warn : vi . fn ( ) as any ,
251
+ } ,
252
+ prefix,
253
+ pollIntervalMs,
254
+ timeoutMs,
255
+ ttlMs : {
256
+ success : ttlMs ,
257
+ failure : ttlMs ,
258
+ } ,
259
+ } ) ;
260
+
261
+ const actionId = randomString ( ) ;
262
+ async function actionFn ( ) {
263
+ await waitFor ( timeoutMs - 1 ) ;
264
+ return 'foo' ;
265
+ }
264
266
265
- const exec1 = cacheForRequest1 . reuse ( actionId , actionFn ) ;
266
- const exec2 = cacheForRequest2 . reuse ( actionId , actionFn ) ;
267
+ const exec1 = cacheForRequest1 . reuse ( actionId , actionFn ) ;
268
+ const exec2 = cacheForRequest2 . reuse ( actionId , actionFn ) ;
267
269
268
- const run1 = exec1 ( { } ) ;
269
- const run2 = exec2 ( { } ) ;
270
- // force the cache to expire
271
- await waitFor ( ttlMs + 10 ) ;
272
- await redis . flushall ( ) ;
270
+ const run1 = exec1 ( { } ) ;
271
+ const run2 = exec2 ( { } ) ;
272
+ // force the cache to expire
273
+ await waitFor ( ttlMs + 10 ) ;
274
+ await redis . flushall ( ) ;
273
275
274
- await expect ( run1 ) . resolves . toBe ( 'foo' ) ;
275
- await expect ( run2 ) . resolves . toBe ( 'foo' ) ;
276
- } ) ;
276
+ await expect ( run1 ) . resolves . toBe ( 'foo' ) ;
277
+ await expect ( run2 ) . resolves . toBe ( 'foo' ) ;
278
+ } ,
279
+ { retry : 3 } ,
280
+ ) ;
277
281
278
282
test ( 'decide on cache duration' , async ( { expect } ) => {
279
283
const ttlMs = {
0 commit comments