Skip to content

fix(runtime): drop a bridge connection whose server left its request unread - #440

Merged
k-taro56 merged 1 commit into
mainfrom
fix/runtime-bridge-unread-body
Nov 3, 2026
Merged

k-taro56 merged 1 commit into
mainfrom
fix/runtime-bridge-unread-body

Conversation

@k-taro56

@k-taro56 k-taro56 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A Node.js handler can stop reading its request before the end. Next.js does this with a Server Action over its size limit: the pipeline's failure destroys the request, and Node.js reads that connection no further.
  • If the whole upload fitted in the loopback's buffers, the bridge's client had sent all of it, so the Agent pooled the connection. The next call sent on it waited for the bridge's headers deadline (30 s), then answered 504.
  • Since fix(runtime): keep the native bridge's idle connections open #432 the server keeps idle connections, so the server's end of each such connection was never closed either. Each one held its unread bytes in kernel buffers, in CLOSE-WAIT once the client side had gone.
  • Now, a connection whose server has not read the request to its end is destroyed at both ends. That happens once the answer has been read whole or the call has ended without it, and before the Agent can pool the connection.

How it showed up

While I triaged the 16.4.3 nightly (run 41491299214), a local upwind start build of app-dir/actions showed the problem:

  • After a few 3 MB actions over the 2 MB limit, a GET to a dynamic Node.js page answered 504 after 28.9 s.
  • The process held about 20 bridge connections with up to 800 KB unread each.

The outer server's side of the same failure is #439.

Verification


Summary by cubic

Fixes a bridge connection leak that made calls time out with a 504 after a handler stopped reading its request body, as Next.js does with a Server Action over its size limit.

Previously, the Agent pooled connections whose server had left part of the request unread, so the next call sent on one waited for the headers deadline and answered 504. The server's end of such a connection also stayed open, since idle connections are kept.

Now a connection whose server has not read its request to the end is destroyed at both ends, once the answer has been read whole or the call has ended without it, and before the Agent can pool it.

Bug Fixes

  • Two new bridge tests use a handler that reads its body like Next.js's action handler; both failed on main.
  • test/native/ passes on Node.js 24.22.1 and 26.13.0.

Written for commit b548876. Summary will update on new commits.

View guided diff Turn on auto-fix

…unread

A Node.js handler can stop reading its request before the end, as Next.js
does with a Server Action over its size limit: its pipeline's failure destroys
the request, and Node.js reads that connection no further. Where the whole
upload fitted in the loopback's buffers, the bridge's client had sent all of
it, so the Agent pooled the connection. The next call sent on it waited for
the headers deadline (30 s), then answered 504. Since #432 the server keeps
idle connections, so the server's end of each such connection was never
closed either.

Once the answer has been read whole, or the call has ended without it, a
connection whose server has not read the request to its end is destroyed at
both ends, before the Agent can pool it.
@arkor-deploy

arkor-deploy Bot commented Nov 2, 2026

Copy link
Copy Markdown

Arkor — Preview deployments for arkorlab-upwind

Use the checkbox below to choose whether this pull request gets preview deployments.

  • Build and deploy previews for this pull request

Checking this builds the latest commit and future pushes. Unchecking stops queued and future builds; a running build can finish and an existing preview stays available.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c1f20c10-2057-4d1c-b0f5-d01db30fcd61
Commits

Reviewing files that changed from the base of the PR and between 541cd93 and b548876.

Files selected for processing: 2
  • packages/runtime/src/native/bridge.ts
  • packages/runtime/test/native/bridge.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T01:59:57.047575Z b548876 Manual request
🔒 Security Review ⚠️ Failed 2026-11-02T19:09:47.389051Z
We couldn’t complete this review. Comment @codex security review to try again.
b548876 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The bridge now closes both ends of a connection when the server has not finished reading its request.

  • The native bridge drops connections when handlers leave uploads unread.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Response ends or client call closes] --> B{Server request complete?}
  B -->|Yes| C[Keep existing connection behavior]
  B -->|No| D[Destroy client and server sockets]
  D --> E[Connection cannot return to the pool]
Loading

Reviews (1) · Last reviewed commit: "fix(runtime): drop a bridge connection w..." · Reviewed by Greptile

@soleil-colza

Copy link
Copy Markdown
Contributor

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: b548876a55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@k-taro56
k-taro56 merged commit a687e55 into main Nov 3, 2026
124 checks passed
@k-taro56
k-taro56 deleted the fix/runtime-bridge-unread-body branch November 3, 2026 02:11
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