Skip to content

feat: implement timeout for create-turn SSE writes to enhance reliability - #964

Merged
thesujai merged 3 commits into
mainfrom
bugfix/timeout-in-writesse
Oct 6, 2026
Merged

thesujai merged 3 commits into
mainfrom
bugfix/timeout-in-writesse

Conversation

@thesujai

@thesujai thesujai commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

…

Summary

Closes #

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Changes live streaming behavior for create-turn SSE clients (slow consumers may lose the direct stream but can still subscribe), though turn execution and event persistence are intentionally preserved.

Overview
Create-turn streaming now caps how long each SSE write can block using a new TURN_SSE_STREAM_WRITE_TIMEOUT_MS setting (default 60s, documented in .env.example and config.ts).

Each stream.writeSSE in the create-turn handler is wrapped with withTimeout. If a write hangs or fails (including timeout), the server stops writing to that SSE client, logs disconnect/timeout vs other errors, and may stream.abort() after drain—but drainTurnEvents keeps dual-writing to the resumable subscription stream, so subscribe/reconnect can still receive events while the turn runs to completion.

Reviewed by Cursor Bugbot for commit d373aba. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d373aba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/apis/turns.ts
@chiragjn
chiragjn force-pushed the bugfix/timeout-in-writesse branch from 24fc6f0 to 1cb05f1 Compare October 6, 2026 07:58
Comment thread packages/trueforge/src/apis/turns.ts
@thesujai
thesujai enabled auto-merge (squash) October 6, 2026 08:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 36fba0b. Configure here.

Comment thread packages/trueforge/src/apis/turns.ts
Comment thread packages/trueforge/src/apis/turns.ts Outdated
Co-authored-by: Chirag Jain <jain.chirag925@gmail.com>
@thesujai
thesujai merged commit d6b1389 into main Oct 6, 2026
15 checks passed
@thesujai
thesujai deleted the bugfix/timeout-in-writesse branch October 6, 2026 08:40
truefoundry-saas added a commit that referenced this pull request Oct 6, 2026
* bugfix: show token and cost metrics for failed and cancelled turns (#963)

* feat: implement timeout for create-turn SSE writes to enhance reliability (#964)

* feat: implement timeout for create-turn SSE writes to enhance reliability

* fix: ensure proper handling of SSE stream disconnection and draining logic in createTurnsRouter

* Give model fetches a 60s body timeout and shorten the default MCP request timeout to 2 minutes. (#965)

Co-authored-by: Cursor <cursoragent@cursor.com>

* Regenerate OpenAPI document and SDKs

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: trueforge-dev-bot[bot] <trueforge-dev-bot[bot]@users.noreply.github.com>
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