Skip to content

Conversation

nirinchev
Copy link
Collaborator

Proposed changes

This makes it so the server sends a ping every 30 seconds to connected clients to ensure the connection is still alive. After 3 failed pings, we close the transport.

Checklist

@nirinchev nirinchev requested a review from a team as a code owner August 27, 2025 14:53
Base automatically changed from ni/http-tweaks to main August 28, 2025 09:30

if (++failedPings > 3) {
clearInterval(keepAliveLoop);
await transport.close();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This needs to be in a try-catch

Copy link
Collaborator

@kmruiz kmruiz left a comment

Choose a reason for hiding this comment

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

Gucci

@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 09:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a heartbeat mechanism for HTTP transport clients by adding a ping loop that sends periodic pings every 30 seconds to maintain connection liveness. The implementation closes the transport after 3 consecutive failed ping attempts.

  • Adds ping loop functionality with 30-second intervals and failure tracking
  • Introduces new log IDs for ping operations and failures
  • Updates error message formatting and logging for better debugging

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/transports/streamableHttp.ts Implements the main ping loop logic with keepalive interval and transport closure after failed pings
src/index.ts Enhances error logging in server close handler with error details
src/common/logger.ts Adds new log IDs for ping operations and failures

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nirinchev nirinchev merged commit cb348e0 into main Aug 28, 2025
17 checks passed
@nirinchev nirinchev deleted the ni/http-pings branch August 28, 2025 09:47
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.

2 participants