When a graph containing async checkpointer is incorrectly used with invoke or get_state, the program will hang #241

Closed
opened 2026-02-20 17:33:34 -05:00 by yindo · 3 comments
Owner

Originally created by @gbaian10 on GitHub (Sep 23, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

import asyncio

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

thread_config = {"configurable": {"thread_id": "1"}}


async def main() -> None:
    async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer:
        workflow = StateGraph(MessagesState)
        app = workflow.compile(checkpointer=checkpointer)

        app.invoke({"messages": []}, thread_config)  # it will hang here

        # await app.ainvoke({"messages": []}, thread_config)
        # app.get_state(thread_config)  # it also hangs here


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

Error Message and Stack Trace (if applicable)

In langgraph-checkpoint-sqlite == 1.0.1, the program will throw an exception, which is what I expected.

  File ".../python3.12/site-packages/langgraph/pregel/__init__.py", line 601, in get_state
    saved = checkpointer.get_tuple(config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../python3.12/site-packages/langgraph/checkpoint/sqlite/aio.py", line 37, in wrapper
    raise NotImplementedError(
NotImplementedError: The AsyncSqliteSaver does not support synchronous methods. Consider using the SqliteSaver instead.
from langgraph.checkpoint.sqlite import SqliteSaver
See https://langchain-ai.github.io/langgraph/reference/checkpoints/langgraph.checkpoint.sqlite.SqliteSaver for more information.

But in versions of langgraph-checkpoint-sqlite >= 1.0.2, the program will hang without reporting any errors.

The same issue will also occur with langgraph-checkpoint-postgres.

Description

The program can't continue running, but it doesn't report an error. If you don't realize it's because you're not using the async method, it might take you a lot of time to debug.
In my case, I was originally using MemorySaver(), and it worked fine, but when I switched to the asynchronous checkpointer, it suddenly stopped responding.

The issue is likely because the async checkpointer implements get_tuple.
If this situation is unavoidable, I hope at least a warning can be printed to alert users to switch methods.

System Info

langchain-core==0.3.5
langgraph==0.2.23
langgraph-checkpoint-sqlite==1.0.3
langgraph-checkpoint-postgres==1.0.7

platform==linux
python-version==3.12.6

Originally created by @gbaian10 on GitHub (Sep 23, 2024). ## Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ## Example Code ```python import asyncio from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver from langgraph.graph import MessagesState, StateGraph thread_config = {"configurable": {"thread_id": "1"}} async def main() -> None: async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer: workflow = StateGraph(MessagesState) app = workflow.compile(checkpointer=checkpointer) app.invoke({"messages": []}, thread_config) # it will hang here # await app.ainvoke({"messages": []}, thread_config) # app.get_state(thread_config) # it also hangs here if __name__ == "__main__": asyncio.run(main()) ``` ## Error Message and Stack Trace (if applicable) In langgraph-checkpoint-sqlite == 1.0.1, the program will throw an exception, which is what I expected. ```shell File ".../python3.12/site-packages/langgraph/pregel/__init__.py", line 601, in get_state saved = checkpointer.get_tuple(config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/langgraph/checkpoint/sqlite/aio.py", line 37, in wrapper raise NotImplementedError( NotImplementedError: The AsyncSqliteSaver does not support synchronous methods. Consider using the SqliteSaver instead. from langgraph.checkpoint.sqlite import SqliteSaver See https://langchain-ai.github.io/langgraph/reference/checkpoints/langgraph.checkpoint.sqlite.SqliteSaver for more information. ``` But in versions of langgraph-checkpoint-sqlite >= 1.0.2, the program will hang without reporting any errors. The same issue will also occur with langgraph-checkpoint-postgres. ## Description The program can't continue running, but it doesn't report an error. If you don't realize it's because you're not using the async method, it might take you a lot of time to debug. In my case, I was originally using `MemorySaver()`, and it worked fine, but when I switched to the asynchronous checkpointer, it suddenly stopped responding. The issue is likely because the async checkpointer implements get_tuple. If this situation is unavoidable, I hope at least a warning can be printed to alert users to switch methods. ## System Info langchain-core==0.3.5 langgraph==0.2.23 langgraph-checkpoint-sqlite==1.0.3 langgraph-checkpoint-postgres==1.0.7 platform==linux python-version==3.12.6
yindo closed this issue 2026-02-20 17:33:35 -05:00
Author
Owner

@nfcampos commented on GitHub (Sep 23, 2024):

Thanks, opened PR to raise exception for this case

@nfcampos commented on GitHub (Sep 23, 2024): Thanks, opened PR to raise exception for this case
Author
Owner

@puyuanOT commented on GitHub (Sep 23, 2024):

I got the same error. What would be the correct way to get the state in this case?

@puyuanOT commented on GitHub (Sep 23, 2024): I got the same error. What would be the correct way to get the state in this case?
Author
Owner

@gbaian10 commented on GitHub (Sep 24, 2024):

I got the same error. What would be the correct way to get the state in this case?

@puyuanOT Use any async function
ex: ainvoke(), aget_state(), aget_tuple()....

@gbaian10 commented on GitHub (Sep 24, 2024): > I got the same error. What would be the correct way to get the state in this case? @puyuanOT Use any async function ex: ainvoke(), aget_state(), aget_tuple()....
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#241