Release response streams used by cache metadata probes

This commit is contained in:
Jonathan Sykes
2026-10-09 10:43:05 +08:00
parent f359e5dd39
commit 2fc6d5d4dc
2 changed files with 20 additions and 4 deletions

View File

@@ -89,3 +89,10 @@ test('blocking commit never waits on an optional file readiness probe',{timeout:
await core.commit(m,c);assert.equal(extraProbes,0);assert.equal((await core.state(c)).current.buildTag,m.buildTag);
c.match=match;assert.equal((await core.status(m,c)).offlineReady,false);
});
test('metadata probes release response streams while stored asset bodies remain readable',async()=>{
const c=cache(),m=manifest();await c.put('/a.js?v=a',response('a'));await c.put('/index.html?v=b',response('b'));
const match=c.match,probes=[];c.match=async key=>{const r=await match(key);if(r)probes.push(r);return r;};
assert.equal((await core.status(m,c)).offlineReady,true);assert.ok(probes.length>0);assert.ok(probes.every(r=>r.bodyUsed));
assert.equal(await(await match('/a.js?v=a')).text(),'a');assert.equal(await(await match('/index.html?v=b')).text(),'b');
});