Skip to content

fix(node): reject sendAndWait on session shutdown - #2336

Draft
connor4312 wants to merge 2 commits into
github:mainfrom
connor4312:fix/send-and-wait-session-shutdown
Draft

fix(node): reject sendAndWait on session shutdown#2336
connor4312 wants to merge 2 commits into
github:mainfrom
connor4312:fix/send-and-wait-session-shutdown

Conversation

@connor4312

@connor4312 connor4312 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

The runtime now emits session.shutdown when a session is torn down during an accepted turn, but sendAndWait() previously only observed session.idle and session.error, leaving callers waiting until timeout.

POC: index.js

Validation

  • npm test -- session-send-and-wait.test.ts
  • npm run typecheck
  • npm run lint -- --quiet
  • npm run format:check
  • deterministic resumed-session POC against the local SDK and current runtime main

Treat session.shutdown as a terminal outcome while waiting for a response, including when the send RPC itself remains pending.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Node.js sendAndWait() to reject when a session shuts down before becoming idle.

Changes:

  • Adds shutdown handling during pending sends.
  • Adds regression coverage for lost sessions.
Show a summary per file
File Description
nodejs/src/session.ts Races pending sends against session shutdown.
nodejs/test/session-send-and-wait.test.ts Tests shutdown rejection behavior.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread nodejs/src/session.ts Outdated
Use a shared terminal latch so a later shutdown cannot override an earlier idle or error while the send RPC is still pending.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@connor4312
connor4312 enabled auto-merge August 14, 2026 20:38
@rotationtv1-crypto

Copy link
Copy Markdown

Click link for telegram and come join the future with (Rotationtvnetwork LLC) Everything from AI automation, too Web3 tokenization technology, NFT'S. Rotationtvnetwork has AI NATIVE telegram mini apps for personal and enterprise grade companies. Our motto at ( Rotationtvnetwork) is we keep buiness Rotating globally 🌎 ✨ and we quantum precision and quality ratings. From building your Brand and buiness portfolio to building your company website, Rotationtvnetwork LLC is here too keep your Enterprise running even while your sleep. Click the link in Bio and Let's get you in Rotation ♾️ 🌍

@SteveSandersonMS

Copy link
Copy Markdown
Contributor

Thanks for tracking down this bug and fixing it for Node — nice catch on the shutdown-during-pending-send race too, and the regression test is a good addition.

Since sendAndWait exists in all six SDKs, we checked and confirmed the same gap exists in C#, Python, Go, Rust, and Java: none of them currently treat session.shutdown as a terminal outcome, so they'd hang the same way until timeout. Could you apply the equivalent fix to those five SDKs as well, with regression coverage in each following that language's existing test conventions (unit test where feasible, E2E where that's the norm for the SDK)?

We want to keep behavior aligned across all six SDKs — a Node-only fix here would leave an avoidable behavioral gap in the others. Once the other languages are updated, please mark this ready for review again. Thanks!

@SteveSandersonMS
SteveSandersonMS marked this pull request as draft August 25, 2026 15:30
auto-merge was automatically disabled August 25, 2026 15:30

Pull request was converted to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants