Skip to content

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Aug 8, 2025

Summary

Fixes issue #409 where HTTP/2 sessions would get stuck after receiving a GOAWAY frame from the server.

Changes

  • Updated to check for both and HTTP/2 session states
  • Added proper cleanup of closed sessions before creating new ones
  • Added comprehensive test case in to reproduce the GOAWAY scenario

Problem Description

When an HTTP/2 server sends a GOAWAY frame, the Node.js session gets closed but not necessarily destroyed. The original code only checked , causing the proxy to get stuck using a closed session that cannot accept new streams.

This resulted in all subsequent requests failing with errors, particularly affecting long-running connections like GraphQL subscriptions.

Solution

Changed the session check from:

if (!http2Client || http2Client.destroyed) {

to:

if (!http2Client || http2Client.destroyed || http2Client.closed) {
  if (http2Client && !http2Client.destroyed) http2Client.destroy()

This ensures that:

  1. Both destroyed and closed sessions are detected
  2. Closed sessions are properly destroyed before creating new ones
  3. New requests get fresh, working sessions

Test Plan

  • Added test that simulates GOAWAY scenario using Node.js HTTP/2 server
  • Verified existing HTTP/2 tests continue to pass
  • Based on production-tested patch from issue reporter

Fixes #409

- Check for both destroyed and closed HTTP/2 sessions
- Destroy closed sessions before creating new ones
- Add test to reproduce the GOAWAY scenario

Fixes #409
mcollina and others added 3 commits August 9, 2025 00:31
Increase test timeout to handle slower tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove test timeout to use global timeout
- Add explicit process.exit() after cleanup to ensure test completes
- Fixes test hanging issue in CI/local environments
@mcollina mcollina merged commit 49a0e5c into main Aug 9, 2025
17 checks passed
@mcollina mcollina deleted the fix/http2-goaway-session-stuck branch August 9, 2025 10:49
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.

How to handle server-side session close (sporadic GOAWAY)

4 participants