Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [1.1.79] - 2025-04-26

### Changed
- Improved Streamable HTTP transport initisation by ensuring heartbeats only start after connection is established

## [1.1.78] - 2025-04-26

### Changed
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@
"tsx": "^4.19.2",
"typescript": "^5.0.0"
},
"files": [
"dist",
"README.md",
"package.json"
],
"files": ["dist", "README.md", "package.json"],
"exports": {
".": {
"import": "./dist/index.js"
Expand Down
20 changes: 3 additions & 17 deletions src/commands/run/streamable-http-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,15 @@ export const createStreamableHTTPRunner = async (
}
}

// Add a 10-second timeout to prevent hanging if connection fails
// If timeout occurs, it will trigger the onclose handler which will attempt reconnection
await Promise.race([
transport.start(),
new Promise((_, reject) =>
setTimeout(
() =>
reject(
new Error("[Runner] Transport connection timeout after 10s"),
),
10000,
),
),
])

transport.start()
isReady = true
retryCount = 0 // Reset retry count on successful connection
logWithTimestamp("[Runner] Streamable HTTP connection initiated")
heartbeatManager.start() // Start heartbeat
idleManager.start() // Start idle checking
// Release buffered messages
await processMessage(Buffer.from(""))
logWithTimestamp("[Runner] Streamable HTTP connection established")
heartbeatManager.start() // Start heartbeat after connection is fully established
idleManager.start() // Start idle check
}

const cleanup = async () => {
Expand Down
9 changes: 9 additions & 0 deletions src/utils/url-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export function createStreamableHTTPTransportUrl(
): URL {
const url = new URL(baseUrl)

if (process.env.NODE_ENV === "development") {
const local = new URL(
process.env.LOCAL_SERVER_URL || "http://localhost:8080",
)
url.protocol = local.protocol
url.hostname = local.hostname
url.port = local.port
}

// Add config as base64 encoded parameter
if (config) {
const configStr = JSON.stringify(config)
Expand Down