Skip to content

fix: always trigger serverless ended early error#4320

Merged
NathanFlurry merged 1 commit intomainfrom
02-26-fix_always_trigger_serverless_ended_early_error
Feb 27, 2026
Merged

fix: always trigger serverless ended early error#4320
NathanFlurry merged 1 commit intomainfrom
02-26-fix_always_trigger_serverless_ended_early_error

Conversation

@MasterPtato
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4320 February 26, 2026 22:22 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 26, 2026

🚅 Deployed to the rivet-pr-4320 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Feb 27, 2026 at 12:25 am
frontend-inspector 😴 Sleeping (View Logs) Web Feb 27, 2026 at 12:23 am
ladle ❌ Build Failed (View Logs) Web Feb 27, 2026 at 12:13 am
website 😴 Sleeping (View Logs) Web Feb 26, 2026 at 10:33 pm
mcp-hub ✅ Success (View Logs) Web Feb 26, 2026 at 10:23 pm

Copy link
Contributor Author

MasterPtato commented Feb 26, 2026

@MasterPtato MasterPtato mentioned this pull request Feb 26, 2026
11 tasks
@claude
Copy link

claude bot commented Feb 26, 2026

PR Review

Summary

This PR makes three changes:

  1. Always report ServerlessStreamEndedEarly error when an SSE stream ends unexpectedly in outbound_req_inner, regardless of whether the runner had initialized.
  2. Config schema cleanup: alphabetically reorders runner_lost_threshold relative to runner_max_response_payload_body_size (renamed from runner_http_max_response_body_size in the parent PR), and removes the stale "Default is 10 seconds." note from serverless_drain_grace_period.
  3. Frontend error message improvement: replaces a vague "Connection terminated unexpectedly" with an actionable message pointing users to configure the request lifespan.

Core Logic Change (conn.rs)

The fix is correct. The stream_handler future in outbound_req_inner runs inside a tokio::select! alongside time-based drain and signal paths. The only time StreamEnded fires inside stream_handler is when the server-side SSE stream closes before the drain path takes over, which is always unexpected.

Before: Only reported an error if runner_id.is_none() (runner never initialized). A runner that initialized and then had its stream cut short would silently return Ok(OutboundReqOutput::Continue) with no error recorded.

After: Always reports the error. This is sound because the normal shutdown path goes through finish_non_critical_draining, which separately handles StreamEnded as an expected event (Err(sse::Error::StreamEnded) => break). There is no legitimate path where StreamEnded in the main stream handler is benign.


Feedback

Minor — Incomplete PR description: The checklist is untouched and no test steps are described. A brief note about how the issue was reproduced would help reviewers and future bisectors.

Minor — No test coverage: There is no automated test for the scenario where StreamEnded fires after a runner initializes. It would be worth adding a regression test if the setup allows simulating a premature stream closure.

Nit — Config schema field rename: runner_http_max_response_body_size to runner_max_response_payload_body_size is a breaking config change for anyone with the old key set. Worth confirming whether a deprecation path is needed, or if this is fine to change directly given it is part of the parent PR.


Verdict

The behavioral fix is correct and the improved error message is genuinely helpful. The changes are small, focused, and low-risk. No blocking issues.

@MasterPtato MasterPtato force-pushed the 02-26-fix_always_trigger_serverless_ended_early_error branch from 84dbb78 to 65b8a35 Compare February 27, 2026 00:12
@MasterPtato MasterPtato force-pushed the 02-26-fix_remove_useless_config_params branch from bc3ad82 to 2f068b7 Compare February 27, 2026 00:12
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4320 February 27, 2026 00:12 Destroyed
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4320

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4320

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4320

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4320

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4320

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4320

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4320

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4320

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4320

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4320

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4320

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4320

commit: 65b8a35

@NathanFlurry NathanFlurry force-pushed the 02-26-fix_remove_useless_config_params branch from 2f068b7 to 4a2a6ab Compare February 27, 2026 00:31
Base automatically changed from 02-26-fix_remove_useless_config_params to main February 27, 2026 00:31
@NathanFlurry NathanFlurry force-pushed the 02-26-fix_always_trigger_serverless_ended_early_error branch from 65b8a35 to 782b146 Compare February 27, 2026 00:32
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4320 February 27, 2026 00:32 Destroyed
@NathanFlurry NathanFlurry merged commit afd30b6 into main Feb 27, 2026
3 of 7 checks passed
@NathanFlurry NathanFlurry deleted the 02-26-fix_always_trigger_serverless_ended_early_error branch February 27, 2026 00:32
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