Repository navigation
Description
TanStack AI version
0.48.0
Framework/Library version
@tanstack/ai-client: 0.26.0 | @tanstack/ai-svelte: 0.18.3
Describe the bug and the steps to reproduce it
An interrupt resume submission can settle after the InterruptManager has been reset or hydrated for another run.
When the obsolete submission fails, its asynchronous failure handler mutates the current manager and can replace the original error with:
InterruptManager is not hydrated.
submitBatch() starts performSubmission() without awaiting it. If the manager is reset while options.submit() is pending, the rejection still enters handleSubmissionFailure().
The uncorrelated transport and protocol-error branches call addRootError(). addRootError() requires live hydration, although reset() has already cleared it.
Because performSubmission() was launched with void, this becomes an unhandled promise rejection and masks the submission error that caused it.
Any submission failure can expose this bug when the manager is reset or rehydrated before failure handling completes.
Expected behavior
InterruptManager should retain a fresh operation object for each submission attempt. performSubmission() should compare its captured operation with the active one before handling a failure and again in finally.
reset() and hydrate() should invalidate the active operation. If a captured operation is no longer active, it should settle without changing errors, item states, retry state, resuming or published state.
This follows an established client pattern. GenerationClient only clears loading state when the captured controller still owns the operation, while ChatClient applies the same identity check to subscription cleanup and connection cleanup.
The stale completion should not replace the original submission failure with a secondary InterruptManager is not hydrated rejection.
performSubmission() can remain internally asynchronous and fire-and-forget.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity