Encountering RuntimeWarning with AsyncPostgresSaver checkpointer setup in LangGraph #180

Closed
opened 2026-02-20 17:30:22 -05:00 by yindo · 2 comments
Owner

Originally created by @merlin-croain on GitHub (Aug 9, 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

async def get_app(checkpointer: AsyncPostgresSaver) -> CompiledStateGraph:
    app = workflow.compile(checkpointer=checkpointer)
    return app


async def main() -> None:
    connection_kwargs ={
        "autocommit": True,
        "prepare_threshold": 0,
        "row_factory": dict_row,
    }

    async with await AsyncConnection.connect(DATABASE_URL, **connection_kwargs) as conn:
        checkpointer = AsyncPostgresSaver(conn)

        await checkpointer.setup()

        app = await get_app(checkpointer)
        await run(app)

asyncio.run(main())

Error Message and Stack Trace (if applicable)

*/venv/lib/python3.12/site-packages/langgraph/checkpoint/postgres/aio.py:69: RuntimeWarning: coroutine 'AsyncCursor.fetchone' was never awaited
  version = (
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "*/bin/launchable/script", line 348, in <module>
    asyncio.run(main())
  File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "*/bin/launchable/script", line 343, in main
    await checkpointer.setup()
  File "*/venv/lib/python3.12/site-packages/langgraph/checkpoint/postgres/aio.py", line 69, in setup
    version = (
              ^
TypeError: 'coroutine' object is not subscriptable

Description

I'm trying to use the new Postgre checkpointer and do the initial setup but I always get the same error.
Even using with a connection pool or a connection string.

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122
Python Version: 3.12.3 (main, Jun 5 2024, 17:17:50) [Clang 15.0.0 (clang-1500.3.9.4)]

Package Information

langchain_core: 0.2.29
langchain: 0.2.12
langchain_community: 0.2.11
langsmith: 0.1.98
langchain_milvus: 0.1.4
langchain_openai: 0.1.20
langchain_text_splitters: 0.2.2
langgraph: 0.2.3

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.10.1
async-timeout: Installed. No version info available.
dataclasses-json: 0.6.7
jsonpatch: 1.33
langgraph-checkpoint: 1.0.2
numpy: 1.26.4
openai: 1.40.1
orjson: 3.10.6
packaging: 23.2
pydantic: 2.8.2
pymilvus: 2.4.4
PyYAML: 6.0.2
requests: 2.32.3
scipy: 1.14.0
SQLAlchemy: 2.0.32
tenacity: 8.5.0
tiktoken: 0.7.0
typing-extensions: 4.12.2

Originally created by @merlin-croain on GitHub (Aug 9, 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 async def get_app(checkpointer: AsyncPostgresSaver) -> CompiledStateGraph: app = workflow.compile(checkpointer=checkpointer) return app async def main() -> None: connection_kwargs ={ "autocommit": True, "prepare_threshold": 0, "row_factory": dict_row, } async with await AsyncConnection.connect(DATABASE_URL, **connection_kwargs) as conn: checkpointer = AsyncPostgresSaver(conn) await checkpointer.setup() app = await get_app(checkpointer) await run(app) asyncio.run(main()) ``` ### Error Message and Stack Trace (if applicable) ```shell */venv/lib/python3.12/site-packages/langgraph/checkpoint/postgres/aio.py:69: RuntimeWarning: coroutine 'AsyncCursor.fetchone' was never awaited version = ( RuntimeWarning: Enable tracemalloc to get the object allocation traceback Traceback (most recent call last): File "*/bin/launchable/script", line 348, in <module> asyncio.run(main()) File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "*/.pyenv/versions/3.12.3/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "*/bin/launchable/script", line 343, in main await checkpointer.setup() File "*/venv/lib/python3.12/site-packages/langgraph/checkpoint/postgres/aio.py", line 69, in setup version = ( ^ TypeError: 'coroutine' object is not subscriptable ``` ### Description I'm trying to use the new Postgre checkpointer and do the initial setup but I always get the same error. Even using with a connection pool or a connection string. ### System Info System Information ------------------ > OS: Darwin > OS Version: Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 > Python Version: 3.12.3 (main, Jun 5 2024, 17:17:50) [Clang 15.0.0 (clang-1500.3.9.4)] Package Information ------------------- > langchain_core: 0.2.29 > langchain: 0.2.12 > langchain_community: 0.2.11 > langsmith: 0.1.98 > langchain_milvus: 0.1.4 > langchain_openai: 0.1.20 > langchain_text_splitters: 0.2.2 > langgraph: 0.2.3 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > aiohttp: 3.10.1 > async-timeout: Installed. No version info available. > dataclasses-json: 0.6.7 > jsonpatch: 1.33 > langgraph-checkpoint: 1.0.2 > numpy: 1.26.4 > openai: 1.40.1 > orjson: 3.10.6 > packaging: 23.2 > pydantic: 2.8.2 > pymilvus: 2.4.4 > PyYAML: 6.0.2 > requests: 2.32.3 > scipy: 1.14.0 > SQLAlchemy: 2.0.32 > tenacity: 8.5.0 > tiktoken: 0.7.0 > typing-extensions: 4.12.2
yindo closed this issue 2026-02-20 17:30:22 -05:00
Author
Owner

@vbarda commented on GitHub (Aug 9, 2024):

@merlin-croain thanks for reporting -- that's a bug, fix incoming!

@vbarda commented on GitHub (Aug 9, 2024): @merlin-croain thanks for reporting -- that's a bug, fix incoming!
Author
Owner

@vbarda commented on GitHub (Aug 9, 2024):

This is fixed in 1.0.3!

@vbarda commented on GitHub (Aug 9, 2024): This is fixed in 1.0.3!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#180