Further updates to web_fetch

This commit is contained in:
Raven Scott
2026-04-22 01:50:59 -04:00
parent b0165c0157
commit 4fc94cebaa
10 changed files with 71 additions and 15 deletions
@@ -157,6 +157,23 @@ test('bareWebFmtErr null/undefined and node-like errors', async (t) => {
t.ok(fmt(withCause).includes('inner'))
})
test('bareWebRunTool without timeout_ms uses finite default (not NaN)', async (t) => {
const fetchFn = async () =>
new Response('<html><head><title>ok</title></head></html>', {
status: 200,
headers: { 'Content-Type': 'text/html; charset=utf-8' }
})
const s = loadSandbox({ fetch: fetchFn })
const run = /** @type {typeof bareWebRunTool} */ (s.bareWebRunTool)
const out = await run({
ctx: { httpFetch: fetchFn },
url: 'https://x.test/',
format: 'meta'
})
t.ok(out.ok)
t.absent(JSON.stringify(out).includes('NaN'))
})
test('bareWebRunTool timeout passes abort reason (matches bare-fetch contract)', async (t) => {
/** Simulates bare-fetch: rejects with `signal.reason` when aborted. */
const fetchFn = async (_url, init) => {