When the graph includes an async BaseCheckpointSaver and uses get_state_history, the program hangs #398

Closed
opened 2026-02-20 17:39:54 -05:00 by yindo · 7 comments
Owner

Originally created by @gbaian10 on GitHub (Jan 10, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

import asyncio

from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
from langgraph.graph import END, START, MessagesState, StateGraph


async def main() -> None:
    builder = StateGraph(MessagesState)
    builder.add_node("foo", lambda _: None)
    builder.add_edge(START, "foo")
    builder.add_edge("foo", END)

    async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer:
        graph = builder.compile(checkpointer=checkpointer)
        config = {"configurable": {"thread_id": "1"}}
        await graph.ainvoke({"messages": []}, config)
        for state in graph.get_state_history(config):
            print(state)

        # async for state in graph.aget_state_history(config):
        #     print(state)


if __name__ == "__main__":
    asyncio.run(main())

Description

When using a graph with async checkpointer(sqlite / postgres) and calling sync method get_state_history, the program blocks and cannot continue running.

I expect the sync method to either throw a NotImplementedError exception or continue running, but without leveraging the benefits of async.

System Info

System Information

OS: Linux
Python Version: 3.13.1 (main, Dec 4 2024, 08:54:15) [GCC 13.2.0]

Package Information

langchain_core: 0.3.29
langgraph: 0.2.62
langgraph-checkpoint-sqlite: 2.0.1
langgraph-checkpoint-postgres: 2.0.10

Originally created by @gbaian10 on GitHub (Jan 10, 2025). ### Checked other resources - [X] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [X] I added a clear and detailed title that summarizes the issue. - [X] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [X] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python import asyncio from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver from langgraph.graph import END, START, MessagesState, StateGraph async def main() -> None: builder = StateGraph(MessagesState) builder.add_node("foo", lambda _: None) builder.add_edge(START, "foo") builder.add_edge("foo", END) async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer: graph = builder.compile(checkpointer=checkpointer) config = {"configurable": {"thread_id": "1"}} await graph.ainvoke({"messages": []}, config) for state in graph.get_state_history(config): print(state) # async for state in graph.aget_state_history(config): # print(state) if __name__ == "__main__": asyncio.run(main()) ``` ### Description When using a graph with async checkpointer(sqlite / postgres) and calling sync method `get_state_history`, the program blocks and cannot continue running. I expect the sync method to either throw a `NotImplementedError` exception or continue running, but without leveraging the benefits of async. ### System Info System Information ------------------ > OS: Linux > Python Version: 3.13.1 (main, Dec 4 2024, 08:54:15) [GCC 13.2.0] Package Information ------------------- > langchain_core: 0.3.29 > langgraph: 0.2.62 > langgraph-checkpoint-sqlite: 2.0.1 > langgraph-checkpoint-postgres: 2.0.10
yindo closed this issue 2026-02-20 17:39:54 -05:00
Author
Owner

@vbarda commented on GitHub (Jan 14, 2025):

Thanks for flagging - fixed here https://github.com/langchain-ai/langgraph/pull/3019

@vbarda commented on GitHub (Jan 14, 2025): Thanks for flagging - fixed here https://github.com/langchain-ai/langgraph/pull/3019
Author
Owner

@gbaian10 commented on GitHub (Jan 14, 2025):

I haven't tried checkpoint-duckdb, but I guess it might have the same issue?

@gbaian10 commented on GitHub (Jan 14, 2025): I haven't tried `checkpoint-duckdb`, but I guess it might have the same issue?
Author
Owner

@vbarda commented on GitHub (Jan 14, 2025):

Good call -- will update that one as well. In the meantime, Sqlite/Postgres are released, so closing the issue

@vbarda commented on GitHub (Jan 14, 2025): Good call -- will update that one as well. In the meantime, Sqlite/Postgres are released, so closing the issue
Author
Owner

@gbaian10 commented on GitHub (Jan 14, 2025):

Thank you 😊

@gbaian10 commented on GitHub (Jan 14, 2025): Thank you 😊
Author
Owner

@hnykda commented on GitHub (Jan 19, 2025):

Huh, I am getting the same with async postgres... this hangs, all on latest versions.

Image

This works, however:

async for state in agent.checkpointer.alist(config):
    print(state)

Interestingly, after I do this, it kinda kills the whole checkpointer - getting state also hangs, even though it works before calling this (same for that alist).

@hnykda commented on GitHub (Jan 19, 2025): Huh, I am getting the same with async postgres... this hangs, all on latest versions. ![Image](https://github.com/user-attachments/assets/715f46e5-63dc-4388-a491-f232da550d5f) This works, however: ``` async for state in agent.checkpointer.alist(config): print(state) ``` Interestingly, after I do this, it kinda kills the whole checkpointer - getting state also hangs, even though it works before calling this (same for that `alist`).
Author
Owner

@vbarda commented on GitHub (Jan 20, 2025):

hm, I would double-check in fresh virtual environment with the latest versions -- the above code is supposed to raise an error

@vbarda commented on GitHub (Jan 20, 2025): hm, I would double-check in fresh virtual environment with the latest versions -- the above code is supposed to raise an error
Author
Owner

@hnykda commented on GitHub (Jan 20, 2025):

And it did not raise anything? Feel free to ignore me, might be me...

@hnykda commented on GitHub (Jan 20, 2025): And it did not raise anything? Feel free to ignore me, might be me...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#398