Fix server keep alive timeout not properly destroying connections#3022
Fix server keep alive timeout not properly destroying connections#3022murgatroid99 merged 1 commit intogrpc:masterfrom
Conversation
|
|
|
Bump |
|
@mattias-wiberg I think we’re the only two people on Earth who have discovered this issue. I was trying to implement internet disconnection detection for streaming, using only bare keepalive, without any additional healthcheck/ heartbeat. I even created PR to nest library because it doesn’t map keepalive settings to grpc-js. But later I discovered that the errors still didn’t propagate to the application layer in gprc-js library (I checked with gRPC tracing). |
|
This is now out in version 1.14.2. |
Issue
GitHub Issue: #2953
Reporter: @zabranskiy
Package: @grpc/grpc-js
Severity: Bug - Server connections hang indefinitely when clients don't respond to keepalive pings
Root Cause
The server-side keepalive ping timeout handler uses
session.close()to terminate connections when clients fail to respond to keepalive pings. However,session.close()performs a graceful shutdown that does not forcibly terminate the underlying connection, causing it to hang indefinitely.Fix Summary
Changed keepalive error handlers to use
session.destroy()instead ofsession.close()to forcibly close connections when:Files Modified
packages/grpc-js/src/server.ts(6 occurrences changed)_sessionHandlermethod (lines ~1609, ~1635, ~1643)_channelzSessionHandlermethod (lines ~1807, ~1830, ~1843)Testing Recommendations
To verify the fix:
Consistency
This change aligns server-side keepalive handling with the client-side transport implementation (
packages/grpc-js/src/transport.ts), which already usessession.destroy()viahandleDisconnect()for keepalive timeouts.Backward Compatibility
This is a bug fix that should not affect normal operation: