Langgraph Postgres and Redis checkpointer/persistence don't work with workers

I'm trying to build an API that uses langgraph in a CF worker. It works fine, but when I add langgraph persistence via postgres or redis, I get the following error.
Error: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/
at async Object.fetch (file:///home/cloudflare-workers/node_modules/.pnpm/miniflare@4.20250823.1/node_modules/miniflare/dist/src/workers/core/entry.worker.js:4346:22)
Error: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/
at async Object.fetch (file:///home/cloudflare-workers/node_modules/.pnpm/miniflare@4.20250823.1/node_modules/miniflare/dist/src/workers/core/entry.worker.js:4346:22)
I cannot perform any sort of ctx.waituntil() calls since the persistence is internal to langgraph. The docs for langgraph js can be found here https://github.com/langchain-ai/langgraphjs/tree/main A minimal example is
import { PostgresSaver } from '@langchain/langgraph-checkpoint-postgres';
import { Annotation, END, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';

const DATABASE_URL = 'postgresql://postgres:postgres@localhost:5432/postgres';
const GraphAnnotation = Annotation.Root({...MessagesAnnotation.spec});
const checkpointer = PostgresSaver.fromConnString(DATABASE_URL);
await checkpointer.setup();
const workflow = new StateGraph(GraphAnnotation)
const compiled = workflow.compile({ checkpointer: checkpointer });
import { PostgresSaver } from '@langchain/langgraph-checkpoint-postgres';
import { Annotation, END, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';

const DATABASE_URL = 'postgresql://postgres:postgres@localhost:5432/postgres';
const GraphAnnotation = Annotation.Root({...MessagesAnnotation.spec});
const checkpointer = PostgresSaver.fromConnString(DATABASE_URL);
await checkpointer.setup();
const workflow = new StateGraph(GraphAnnotation)
const compiled = workflow.compile({ checkpointer: checkpointer });
GitHub
GitHub - langchain-ai/langgraphjs: Framework to build resilient lan...
Framework to build resilient language agents as graphs. - langchain-ai/langgraphjs
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?