TanStack AI version#
@tanstack/ai 1.8.0, @tanstack/ai-durable-stream 1.0.0 (both latest on npm; durableStream on main has the same signature)
Framework/Library version#
Node 26.12.0, server only (no UI framework involved)
Describe the bug and the steps to reproduce it#
memoryStream takes plain values: memoryStream(source: Request | MemoryStreamInit) (@tanstack/ai src/stream-durability.ts:331). durableStream takes only a Request: durableStream(request: Request, options) (@tanstack/ai-durable-stream src/durable-stream.ts:472). Pass it the same { runId, offset } and it throws a raw TypeError at construction, before any request, because it reads request.headers.get('Last-Event-ID') and request.headers.get('X-Run-Id').
So a server that builds the durability adapter outside a request handler, for example a run reaper or a retry that replays from the start, has to make a Request only to carry ?runId and ?offset.
Steps:
- Install
@tanstack/ai@1.8.0 and @tanstack/ai-durable-stream@1.0.0 in an ESM package.
- Save the script below as
repro.mjs and run node repro.mjs.
repro.mjs:
import { memoryStream } from '@tanstack/ai'
import { durableStream } from '@tanstack/ai-durable-stream'
const init = { runId: 'run-1', offset: '-1' }
let fetchCalls = 0
const options = {
server: 'http://127.0.0.1:9',
fetch: async () => { fetchCalls++; throw new Error('no network') },
}
function attempt(label, make) {
try {
console.log(`${label}: ok, resumeFrom() = ${JSON.stringify(make().resumeFrom())}`)
} catch (error) {
console.log(`${label}: threw ${error.name}: ${error.message}`)
}
}
attempt('memoryStream(init)', () => memoryStream(init))
attempt('durableStream(init)', () => durableStream(init, options))
attempt('durableStream(Request)', () => durableStream(new Request('http://x/?runId=run-1&offset=-1'), options))
console.log(`fetch calls: ${fetchCalls}`)
Expected: durableStream(init) works like memoryStream(init). durableStream accepts Request | { runId, offset } and reads the run id and offset from the plain values.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)#
Inline above. Plain Node script. The fetch option is a stub that throws; it is called 0 times.
Screenshots or Videos (Optional)#
None.
Do you intend to try to help solve this bug with your own PR?#
Maybe, I'll investigate and start debugging
Terms & Code of Conduct#
Thanks for the report, @ozolcar! To help us reproduce this, could you add a minimal reproduction?
A runnable example makes fixes dramatically faster — you can fork one of the official examples, or use StackBlitz / CodeSandbox. For TypeScript-only issues, a TS Playground link works too.
Automated triage — a maintainer will follow up.