[PR #1022] [MERGED] fix(langgraph): compose & propagate AbortSignal correctly, trigger on more early termination cases #1179

Closed
opened 2026-02-15 19:17:33 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/1022
Author: @benjamincburns
Created: 3/24/2025
Status: Merged
Merged: 3/30/2025
Merged by: @benjamincburns

Base: mainHead: ben/port-interrupt-tests


📝 Commits (3)

  • fb346df fix(langgraph): plumb augmented AbortSignal through to node config
  • adeeb2e fix(langgraph): propagate abort signal when stream.cancel called
  • 46d95d2 fix(langgraph): propagate AbortSignals correctly to subgraphs

📊 Changes

11 files changed (+1396 additions, -46 deletions)

View changed files

📝 libs/langgraph/.eslintrc.cjs (+6 -0)
📝 libs/langgraph/src/constants.ts (+2 -0)
📝 libs/langgraph/src/pregel/index.ts (+30 -5)
📝 libs/langgraph/src/pregel/retry.ts (+9 -0)
📝 libs/langgraph/src/pregel/runner.ts (+149 -35)
📝 libs/langgraph/src/pregel/stream.ts (+60 -0)
📝 libs/langgraph/src/pregel/types.ts (+23 -0)
📝 libs/langgraph/src/pregel/utils/index.ts (+29 -0)
📝 libs/langgraph/src/tests/pregel/pregel.cancellation.test.ts (+26 -6)
📝 libs/langgraph/src/tests/python_port/graph_structure.test.ts (+8 -0)
libs/langgraph/src/tests/python_port/interrupt.test.ts (+1054 -0)

📄 Description

The AbortSignal passed to each node via the signal field on the node's config argument now aborts when:

  • The AbortSignal passed into Pregel.invoke, Pregel.stream, or Pregel.streamEvents via config.signal is aborted.
  • The currently executing graph super-step times out.
  • Any other node executing concurrently within the same superstep throws an Error.
    • Note: "bubble-up" errors (e.g. NodeInterrupt and CommandParent) will not trigger an abort.
  • The cancel method is called on the stream returned by Pregel.stream or Pregel.streamEvents.

Importantly, AbortSignal are also now composed intelligently throughout the graph execution, allowing for a node in a parent graph to call a subgraph with an AbortSignal that originates in the node, and the signal received by the subgraph nodes will abort when abort() is called on the associated AbortController, as well as in any of the cases mentioned above, including when the parent graph's external AbortSignal is aborted.

fixes #319


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraphjs/pull/1022 **Author:** [@benjamincburns](https://github.com/benjamincburns) **Created:** 3/24/2025 **Status:** ✅ Merged **Merged:** 3/30/2025 **Merged by:** [@benjamincburns](https://github.com/benjamincburns) **Base:** `main` ← **Head:** `ben/port-interrupt-tests` --- ### 📝 Commits (3) - [`fb346df`](https://github.com/langchain-ai/langgraphjs/commit/fb346dfe46cb17e38c4c30b6e7bbd005f1c9ea8d) fix(langgraph): plumb augmented AbortSignal through to node config - [`adeeb2e`](https://github.com/langchain-ai/langgraphjs/commit/adeeb2ebc6cfe33b48839026884b21bc11a2a4d1) fix(langgraph): propagate abort signal when stream.cancel called - [`46d95d2`](https://github.com/langchain-ai/langgraphjs/commit/46d95d25f9b8022961315c661fc77ad11c6f15d1) fix(langgraph): propagate AbortSignals correctly to subgraphs ### 📊 Changes **11 files changed** (+1396 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/.eslintrc.cjs` (+6 -0) 📝 `libs/langgraph/src/constants.ts` (+2 -0) 📝 `libs/langgraph/src/pregel/index.ts` (+30 -5) 📝 `libs/langgraph/src/pregel/retry.ts` (+9 -0) 📝 `libs/langgraph/src/pregel/runner.ts` (+149 -35) 📝 `libs/langgraph/src/pregel/stream.ts` (+60 -0) 📝 `libs/langgraph/src/pregel/types.ts` (+23 -0) 📝 `libs/langgraph/src/pregel/utils/index.ts` (+29 -0) 📝 `libs/langgraph/src/tests/pregel/pregel.cancellation.test.ts` (+26 -6) 📝 `libs/langgraph/src/tests/python_port/graph_structure.test.ts` (+8 -0) ➕ `libs/langgraph/src/tests/python_port/interrupt.test.ts` (+1054 -0) </details> ### 📄 Description The `AbortSignal` passed to each node via the `signal` field on the node's `config` argument now aborts when: - The `AbortSignal` passed into `Pregel.invoke`, `Pregel.stream`, or `Pregel.streamEvents` via `config.signal` is aborted. - The currently executing graph super-step times out. - Any other node executing concurrently within the same superstep throws an `Error`. - Note: "bubble-up" errors (e.g. `NodeInterrupt` and `CommandParent`) will _not_ trigger an abort. - The `cancel` method is called on the stream returned by `Pregel.stream` or `Pregel.streamEvents`. Importantly, `AbortSignal` are also now composed intelligently throughout the graph execution, allowing for a node in a parent graph to call a subgraph with an `AbortSignal` that originates in the node, and the signal received by the subgraph nodes will abort when `abort()` is called on the associated `AbortController`, as well as in any of the cases mentioned above, including when the parent graph's external `AbortSignal` is aborted. fixes #319 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 19:17:33 -05:00
yindo closed this issue 2026-02-15 19:17:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#1179