deepset-ai/haystack · error · RuntimeError
Pipeline was cancelled; no result available.
Error message
Pipeline was cancelled; no result available.
What it means
Pipeline.result() raises RuntimeError if the pipeline's asyncio task was cancelled before completion, because there is no final output to return. This is distinct from a failed run (which re-raises the original exception).
Source
Thrown at haystack/core/pipeline/pipeline.py:100
return
yield cast(StreamingChunk, item) # at this point, item is guaranteed to be a StreamingChunk
finally:
if self._cancel_on_abandon:
await self.aclose()
@property
def result(self) -> dict[str, Any]:
"""
Final pipeline output dict, available only after a successful, complete run.
Raises a `RuntimeError` if the pipeline has not finished or was cancelled. If the pipeline failed, re-raises the
original exception.
"""
if not self._task.done():
raise RuntimeError("Pipeline has not finished; iterate the handle first.")
if self._task.cancelled():
raise RuntimeError("Pipeline was cancelled; no result available.")
exc = self._task.exception()
if exc is not None:
raise exc
return self._task.result()
async def aclose(self) -> None:
"""
Cancel the underlying pipeline task.
Bounded by `_CLEANUP_TIMEOUT_SECONDS` so that components cannot block cleanup indefinitely.
"""
if not self._task.done():
self._task.cancel()
with contextlib.suppress(BaseException):
await asyncio.wait_for(self._task, timeout=self._CLEANUP_TIMEOUT_SECONDS)
class Pipeline(PipelineBase):View on GitHub (pinned to e318778c9b)
Solutions
- Guard result() access with a check whether the task was cancelled before calling it
- Wrap result() in try/except RuntimeError and treat it as a cancelled run
- Avoid cancelling the pipeline task if the final result is needed; or re-run the pipeline
Example fix
// before
print(handle.result())
// after
try:
print(handle.result())
except RuntimeError:
logger.warning("Pipeline run was cancelled; no result available.") Defensive patterns
Strategy: try-catch
Type guard
def was_cancelled(pipeline) -> bool:
task = getattr(pipeline, "_task", None)
return task is not None and task.cancelled() Try / catch
try:
result = handle.result()
except RuntimeError as e:
if "cancelled" in str(e):
logger.warning("Run cancelled; re-running or aborting")
else:
raise Prevention
- Avoid cancelling tasks whose results you need; use cooperative cancellation flags
- Account for asyncio.wait_for timeouts cancelling the run
- Call aclose()/cleanup deliberately and re-run if the result is required
When it happens
Trigger: Cancelling the run (e.g., asyncio.Task.cancel(), cancellation of the surrounding coroutine, timeout, KeyboardInterrupt in async context) and then calling result().
Common situations: asyncio.wait_for timeouts cancelling the pipeline task, user-initiated shutdown, pipeline.aclose() during a run, or cancellation propagated from a parent task.
Related errors
- Pipeline has not finished; iterate the handle first.
- MarkdownHeaderSplitter only works with text documents but co
- Error while unmarshalling serialized pipeline data. This is
- Component instance cannot be added to the pipeline more than
- A component named '{name}' already exists in this pipeline:
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/9deeb2ea03741839.
Report an issue: GitHub.