Repository navigation
Description
What happened?
On Bun 1.3.13, aborting a buffered pinnedFetch after response headers and a partial body can resolve successfully with HTTP 200 and the incomplete body. The scientific connector HTTP wrapper then caches that text. A second request returns the same truncated record without contacting the server.
Expected: timeout/abort rejects the response and incomplete data is never cached.
Steps to reproduce
Run from tag v2.0.151. This uses the original private transport and the complete original connector HTTP wrapper. Only application/domain authorization is stubbed for the local fixture; no installed settings are changed.
Standalone reproduction command
python3 - <<'PY' | bun run -
from pathlib import Path
r=Path('backend/cli/src')
s=(r/'settings/network.ts').read_text()
h=(r/'science/connectors/http.ts').read_text()
print('import {isIP} from "node:net"; import {request as httpRequest,createServer} from "node:http"; import {request as httpsRequest} from "node:https"; import {Readable} from "node:stream";')
print(s[s.index(' async function pinnedFetch('):s.index(' /** Policy-aware fetch.')])
print('const Network={assertAllowed:async()=>{},fetch:async(raw,init)=>pinnedFetch(new URL(raw),init,"127.0.0.1")};')
print('\n'.join(l for l in h.splitlines() if not l.startswith('import type { RateLimit }') and not l.startswith('import { Network }')))
print('''
let requests=0;
const server=createServer((req,res)=>{
requests++;
res.writeHead(200,{"content-type":"text/plain"});
res.write("PARTIAL"); // deliberately never end the response
});
await new Promise(r=>server.listen(0,"127.0.0.1",r));
const url="http://127.0.0.1:"+server.address().port+"/record";
try {
for(let i=0;i<2;i++) {
const start=Date.now();
try {
const r=await request(url,{timeout:100,retries:0});
console.log({call:i+1,status:r.status,text:await r.text(),requests,elapsedMs:Date.now()-start});
} catch(e) {console.log(e.name,e.message);}
}
} finally {server.closeAllConnections();server.close();}
''')
PYLogs and screenshots
call=1 status=200 text=PARTIAL requests=1 elapsedMs=105
call=2 status=200 text=PARTIAL requests=1 elapsedMs=0
An independent control with the same fixture showed native fetch throwing TimeoutError and the original streaming transport throwing aborted.
Code location and impact
- network.ts:653: the
endhandler resolves without checking cancellation or response completeness. - http.ts:336: after reading, only the caller's optional signal is checked, not the internal timeout controller.
- http.ts:388: nonempty text is cacheable unless a caller supplies a stricter validator; default TTL is five minutes.
JSON parsing and connector-specific validators may reject some incomplete results. The demonstrated case is plain text without such a validator, not a claim that every connector accepts truncated data.
How did you install OpenScience?
Official desktop ZIP and npm; isolated reproduction uses tag v2.0.151 source.
OpenScience version
2.0.151 (latest npm at reporting time).
Provider and model
Not applicable; no model calls.
Operating system
macOS 27.0 ARM64, Bun 1.3.13. Runtime-dependent result; the packaged desktop runtime has not been independently tested.
Action approval mode
Not applicable to the isolated fixture.
Activity
aayambansal commentedon Oct 18, 2026
Fixed in #998, squash merged to
main. The transport rejects interrupted bodies and rechecks cancellation after buffering. The scientific connector also checks its combined timeout/caller signal after reading and before caching, so an aborted partial body cannot become a successful cached record. A real HTTP regression times out after partial bodies and verifies that both requests reach the server instead of the second returning a cached partial record.The 13 real-transport regressions also pass on Bun 1.3.13, the exact runtime in this report, as well as the pinned 1.3.14 runtime. The broader network/scientific-connector tests and PR CI passed. These source fixes are on
main; installed 2.0.151 builds need a release containing them.