Skip to content

fix(http): prevent recursive session cleanup stack overflow#52

Merged
maxgolov merged 3 commits intomainfrom
fix/http-session-cleanup-recursion
May 2, 2026
Merged

fix(http): prevent recursive session cleanup stack overflow#52
maxgolov merged 3 commits intomainfrom
fix/http-session-cleanup-recursion

Conversation

@maxgolov
Copy link
Copy Markdown
Contributor

@maxgolov maxgolov commented May 1, 2026

Summary

Fixes a recursion loop in HTTP session cleanup that could trigger repeated \Cleaning up session\ logs and eventually crash with \RangeError: Maximum call stack size exceeded.

Root Cause

\ ransport.onclose\ called \cleanupSession(sessionId), and \cleanupSession\ called \ ransport.close(), which triggered \onclose\ again.

Changes

  • Added \cleanupInProgress\ guard set to make cleanup idempotent.
  • In \cleanupSession, remove transport from map before closing.
  • Detach \ ransport.onclose\ before calling \ ransport.close().
  • Always clear timeout entries and release in-progress marker via \ inally.

Validation

  • Rebuilt with
    pm run build.
  • Started server in HTTP mode via \Start.ps1.
  • Exercised MCP lifecycle (\initialize\ + \ ools/list) over /mcp.
  • Verified health endpoint remains \ok\ and no cleanup recursion/stack overflow reproduced.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread src/http-server.ts Fixed
maxgolov and others added 3 commits May 2, 2026 11:41
…assignment'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@maxgolov maxgolov force-pushed the fix/http-session-cleanup-recursion branch from 718e012 to a8b892f Compare May 2, 2026 18:41
@maxgolov maxgolov merged commit cd68016 into main May 2, 2026
9 checks passed
@maxgolov maxgolov deleted the fix/http-session-cleanup-recursion branch May 2, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants