File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -328,8 +328,12 @@ describe('prefetchTranslations', () => {
328328 expect ( posts ) . toBe ( 0 )
329329 expect ( polled ) . toEqual ( [ 'gone' ] )
330330 expect ( pending . size ) . toBe ( 0 )
331- // The other model's batch is kept for when that model is used again.
332- expect ( Object . keys ( JSON . parse ( await readFile ( ledgerPath , 'utf8' ) ) ) ) . toEqual ( [ 'other' ] )
331+ // The other model's batch is kept for when that model is used again, and the
332+ // forbidden one for a run whose key can read it.
333+ expect ( Object . keys ( JSON . parse ( await readFile ( ledgerPath , 'utf8' ) ) ) . sort ( ) ) . toEqual ( [
334+ 'gone' ,
335+ 'other' ,
336+ ] )
333337 } )
334338
335339 it ( 'does not throw when a submit fails' , async ( ) => {
Original file line number Diff line number Diff line change @@ -244,11 +244,12 @@ export async function prefetchTranslations(
244244 let batch : BatchObject
245245 try {
246246 const res = await doFetch ( `${ BATCHES_URL } /${ id } ` , { headers, signal : timeout ( ) } )
247- // Deleted, never ours, or no longer readable with this key (any 4xx but a
248- // timeout or rate limit): nothing will ever arrive, so stop waiting on it.
247+ // Any 4xx but a timeout or rate limit will not change by asking again, so stop
248+ // waiting and let the requests run live. Only a 404 means the batch is gone;
249+ // an auth failure keeps it in the ledger for a run with a working key.
249250 if ( res . status >= 400 && res . status < 500 && res . status !== 408 && res . status !== 429 ) {
250251 batches . delete ( id )
251- known . delete ( id )
252+ if ( res . status === 404 ) known . delete ( id )
252253 opts . log ( `batch ${ id } unreadable (HTTP ${ res . status } ); its requests will run live` )
253254 continue
254255 }
You can’t perform that action at this time.
0 commit comments