Skip to content

feat: basic envoy tunnel impl#4534

Merged
NathanFlurry merged 1 commit intomainfrom
03-30-feat_basic_envoy_tunnel_impl
Apr 5, 2026
Merged

feat: basic envoy tunnel impl#4534
NathanFlurry merged 1 commit intomainfrom
03-30-feat_basic_envoy_tunnel_impl

Conversation

@MasterPtato
Copy link
Copy Markdown
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
Copy link
Copy Markdown

railway-app bot commented Mar 31, 2026

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

Service Status Web Updated (UTC)
ladle ❌ Build Failed (View Logs) Web Apr 5, 2026 at 11:30 am
kitchen-sink ❌ Build Failed (View Logs) Web Apr 5, 2026 at 11:30 am
website 🕒 Building (View Logs) Web Apr 5, 2026 at 11:30 am
frontend-inspector 🕒 Building (View Logs) Web Apr 5, 2026 at 11:30 am
frontend-cloud 🕒 Building (View Logs) Web Apr 5, 2026 at 11:30 am
mcp-hub ✅ Success (View Logs) Web Mar 31, 2026 at 1:42 am

@MasterPtato MasterPtato mentioned this pull request Mar 31, 2026
11 tasks
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 March 31, 2026 01:41 Destroyed
This was referenced Mar 31, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 31, 2026

More templates

@rivetkit/cloudflare-workers

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

@rivetkit/framework-base

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

@rivetkit/next-js

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

@rivetkit/react

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

rivetkit

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

@rivetkit/sql-loader

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

@rivetkit/sqlite-vfs

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

@rivetkit/traces

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

@rivetkit/workflow-engine

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

@rivetkit/virtual-websocket

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

@rivetkit/engine-runner

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

@rivetkit/engine-runner-protocol

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

commit: da489fa

@claude
Copy link
Copy Markdown

claude bot commented Mar 31, 2026

PR Review: feat: basic envoy tunnel impl

Good foundational work on the HTTP tunnel implementation. There are a few bugs and design concerns worth addressing before merging.


Bugs

1. Wrong field name for max payload check (tunnel.ts)

ctx.protocolMetadata?.maxPayloadSize should be ctx.protocolMetadata?.maxResponsePayloadSize. The field added to ProtocolMetadata (in both v1.bare and envoy-protocol/src/index.ts) is maxResponsePayloadSize. As written, the comparison is always number > undefined which is false in JavaScript, silently disabling the payload size limit.

2. Map lookup by array key always fails (actor.ts, tunnel.ts)

// This pattern breaks -- Map uses reference equality for object keys
pendingRequests: new Map<[protocol.GatewayId, protocol.RequestId], PendingRequest>()

map.get([gatewayId, requestId]) will never match a map.set([gatewayId, requestId], ...) entry because each array literal is a distinct object. A string composite key like ${gatewayId}:${requestId} would work correctly. This affects all request-chunk and request-abort lookups in both actor.ts and tunnel.ts.

3. requestToActor is never populated (tunnel.ts)

handleRequestStart forwards the request to the actor but never calls ctx.requestToActor.set(...). As a result, handleRequestChunk and handleRequestAbort will always find actorId === undefined and return early without processing chunks.

4. Streaming request body: initial body bytes are discarded (actor.ts)

In the streaming path of request-start, a ReadableStream is created and its controller is stored in pendingRequests, but the initial msg.req.body bytes from the RequestStart message are passed directly (not enqueued into the stream). Those bytes are effectively discarded -- the Request is constructed with the stream as its body, which starts empty until chunks arrive.

5. SIGTERM/SIGINT copy-paste bug (test-envoy/src/index.ts)

Both SIGTERM and SIGINT handlers log "received SIGTERM". The SIGINT handler should log "received SIGINT".


Design Concerns

6. startEnvoy can hang indefinitely

startEnvoy now awaits startRx.changed(), which only resolves once ToEnvoyInit is received. If init is never received (network issue, auth failure, etc.), the call hangs forever. A timeout should wrap this await.

7. Errors from spawn(sendResponse(...)) are silently dropped (actor.ts)

The spawn call that invokes sendResponse doesn't handle errors. If sendResponse throws (e.g., body too large), the error is lost and the request never receives a response. Consider catching the error and sending an error response instead.

8. Oversized body throws instead of returning an error response (tunnel.ts)

throw new Error("Response body too large") propagates up and gets swallowed by the unhandled spawn. Prefer sending a 413 Payload Too Large response so the caller gets actionable feedback.

9. v1.bare modified instead of adding a new schema version

Per CLAUDE.md: "Never modify an existing published *.bare runner protocol version unless explicitly asked to do so. Add a new versioned schema instead." Adding maxResponsePayloadSize to v1.bare violates this. A v2.bare (or appropriate next version) should carry the new field.


Minor

  • await envoy?.shutdown() (test-envoy/src/index.ts): shutdown() returns void, so the await is a no-op. Remove it.
  • Import inconsistency (tunnel.ts): Uses @/context.js (path alias) while all other envoy-client files use relative imports. Align with the existing convention.
  • clientMessageIndex in PendingRequest is unused -- Stored but never incremented or validated, so chunk ordering/deduplication silently does nothing.
  • TODO: Actor v2 comment (delete.rs): Link to an issue number so this doesn't get lost.
  • test-envoy/src/log.ts appears to be duplicated from test-runner/src/log.ts. Consider extracting to a shared package.

@MasterPtato MasterPtato force-pushed the 03-27-chore_envoy_client branch from 056dbbc to ecb7a20 Compare March 31, 2026 22:24
@MasterPtato MasterPtato force-pushed the 03-30-feat_basic_envoy_tunnel_impl branch from 748e9f1 to 9adad6e Compare March 31, 2026 22:24
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 March 31, 2026 22:25 Destroyed
@MasterPtato MasterPtato mentioned this pull request Mar 31, 2026
11 tasks
@MasterPtato MasterPtato force-pushed the 03-27-chore_envoy_client branch from ecb7a20 to 58851a4 Compare April 1, 2026 02:11
@MasterPtato MasterPtato force-pushed the 03-30-feat_basic_envoy_tunnel_impl branch from 9adad6e to 14e5bc7 Compare April 1, 2026 02:11
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 April 1, 2026 02:11 Destroyed
@MasterPtato MasterPtato force-pushed the 03-30-feat_basic_envoy_tunnel_impl branch from 14e5bc7 to d705065 Compare April 2, 2026 02:47
@MasterPtato MasterPtato force-pushed the 03-27-chore_envoy_client branch from 58851a4 to 68bbabd Compare April 2, 2026 02:47
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 April 2, 2026 02:47 Destroyed
@MasterPtato MasterPtato force-pushed the 03-27-chore_envoy_client branch from 68bbabd to 5c9a464 Compare April 3, 2026 01:24
@MasterPtato MasterPtato force-pushed the 03-30-feat_basic_envoy_tunnel_impl branch from d705065 to da489fa Compare April 3, 2026 01:24
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 April 3, 2026 01:24 Destroyed
@MasterPtato MasterPtato mentioned this pull request Apr 3, 2026
11 tasks
Copy link
Copy Markdown
Member

NathanFlurry commented Apr 5, 2026

Merge activity

  • Apr 5, 11:11 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 5, 11:30 AM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 5, 11:31 AM UTC: @NathanFlurry merged this pull request with Graphite.

@NathanFlurry NathanFlurry changed the base branch from 03-27-chore_envoy_client to graphite-base/4534 April 5, 2026 11:26
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4534 to main April 5, 2026 11:28
@NathanFlurry NathanFlurry force-pushed the 03-30-feat_basic_envoy_tunnel_impl branch from da489fa to 539544e Compare April 5, 2026 11:29
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4534 April 5, 2026 11:29 Destroyed
@NathanFlurry NathanFlurry merged commit c036c16 into main Apr 5, 2026
7 of 19 checks passed
@NathanFlurry NathanFlurry deleted the 03-30-feat_basic_envoy_tunnel_impl branch April 5, 2026 11:31
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.

3 participants