deepset-ai/haystack · error · TypeError
Document store {type(self.document_store).__name__} does not
Error message
Document store {type(self.document_store).__name__} does not provide async support. What it means
DocumentWriter.run_async requires the configured document store to implement write_documents_async. If the store object lacks that attribute, a TypeError is raised because the async write cannot be performed. The sync run() works with the same store; only the async path is affected.
Source
Thrown at haystack/components/writers/document_writer.py:124
but can be used with `await` in async code.
:param documents:
A list of documents to write to the document store.
:param policy:
The policy to use when encountering duplicate documents.
:returns:
Number of documents written to the document store.
:raises ValueError:
If the specified document store is not found.
:raises TypeError:
If the specified document store does not implement `write_documents_async`.
"""
if policy is None:
policy = self.policy
if not hasattr(self.document_store, "write_documents_async"):
raise TypeError(f"Document store {type(self.document_store).__name__} does not provide async support.")
documents_written = await self.document_store.write_documents_async(documents=documents, policy=policy)
return {"documents_written": documents_written}
def close(self) -> None:
"""
Release the synchronous resources of the underlying Document Store.
"""
if hasattr(self.document_store, "close"):
self.document_store.close()
async def close_async(self) -> None:
"""
Release the asynchronous resources of the underlying Document Store.
"""
if hasattr(self.document_store, "close_async"):
await self.document_store.close_async()
View on GitHub (pinned to e318778c9b)
Solutions
- Use an async-capable document store (e.g. a store that implements write_documents_async) instead of InMemoryDocumentStore.
- Fall back to the synchronous DocumentWriter.run() in async code via asyncio.to_thread(run, ...) if the store has no async support.
- If it's a custom store, implement write_documents_async (often trivially wrapping write_documents or an async client call).
- Upgrade the document store integration package to a version that adds async write support.
Example fix
// before writer = DocumentWriter(document_store=InMemoryDocumentStore()) await writer.run_async(documents=docs) // after writer = DocumentWriter(document_store=QdrantDocumentStore(url=...)) # supports write_documents_async await writer.run_async(documents=docs)
Defensive patterns
Strategy: type-guard
Validate before calling
if not hasattr(writer.document_store, "write_documents_async"):
result = await asyncio.to_thread(writer.run, documents=docs, policy=policy)
else:
result = await writer.run_async(documents=docs, policy=policy) Type guard
def supports_async_write(store) -> TypeGuard[WriteDocumentsAsyncDocumentStore]:
return hasattr(store, "write_documents_async") and callable(store.write_documents_async) Try / catch
try:
result = await writer.run_async(documents=docs)
except TypeError as e:
if "does not provide async support" in str(e):
result = await asyncio.to_thread(writer.run, documents=docs) Prevention
- Use async-capable stores in async pipelines; avoid InMemoryDocumentStore there
- Check hasattr(store, 'write_documents_async') when building pipelines programmatically
- Keep store integration packages up to date for async API support
- Pin a sync fallback in shared pipeline code
When it happens
Trigger: Awaiting DocumentWriter.run_async (or running an async pipeline containing it) when self.document_store is an InMemoryDocumentStore or any custom/legacy store that doesn't define write_documents_async.
Common situations: Using InMemoryDocumentStore (no async support) in an async pipeline; custom DocumentStore implementations that only ported the sync API; older third-party store integrations predating the async API.
Related errors
- Document store {type(self.document_store).__name__} does not
- Parameters of 'run' and 'run_async' methods must be the same
- Method 'run_async' of component '{cls.__name__}' must be a c
- The following tool names are not valid: {invalid_tool_names}
- user_prompt must define exactly one message block, found {le
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/bcc12b6f2d02bfdb.
Report an issue: GitHub.