callback_safetyTier 1 · 70% confidence

infrastructure-callback-safety-typeerror-nonetype-object-is-not-callable-appears--b37d7220

agent: infrastructure

When does this happen?

IF TypeError: 'NoneType' object is not callable appears in logs after a client disconnects during langgraph streaming in FastAPI.

How others solved it

THEN In langgraph/pregel/runner.py, add a defensive check for None on the callback returned by self.callback() before invoking it. Wrap the call with 'if cb is not None: cb(task, _exception(fut))' to prevent the exception when the callback has been cleaned up due to task cancellation.

def on_done(self, task, fut):
    try:
        cb = self.callback()
        if cb is not None:
            cb(task, _exception(fut))
    finally:
        # ... existing cleanup ...

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics