Skip to content

feat: basic envoy tunnel impl#4534

Draft
MasterPtato wants to merge 1 commit into03-27-chore_envoy_clientfrom
03-30-feat_basic_envoy_tunnel_impl
Draft

feat: basic envoy tunnel impl#4534
MasterPtato wants to merge 1 commit into03-27-chore_envoy_clientfrom
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)
frontend-cloud 😴 Sleeping (View Logs) Web Apr 4, 2026 at 8:41 am
kitchen-sink ❌ Build Failed (View Logs) Web Apr 3, 2026 at 1:24 am
website 😴 Sleeping (View Logs) Web Mar 31, 2026 at 7:45 am
frontend-inspector 😴 Sleeping (View Logs) Web Mar 31, 2026 at 7:01 am
mcp-hub ✅ Success (View Logs) Web Mar 31, 2026 at 1:42 am
ladle ❌ Build Failed (View Logs) Web Mar 31, 2026 at 1:41 am

@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 (#4534)

NOTE: This is a draft PR. Feedback is provided for early review purposes.

CRITICAL BUGS

  1. Map lookup with tuple/array keys will always miss (tunnel.ts, actor.ts)

JavaScript compares objects by reference, not value. Using array tuples as Map keys means map.get([a, b]) will never find an entry stored with map.set([a, b], ...) because each literal [a, b] is a distinct object.

Affected: ctx.pendingRequests.get([msg.messageId.gatewayId, msg.messageId.requestId]) in actor.ts and ctx.requestToActor.get([...]) in tunnel.ts. Both lookups will always return undefined.

Fix: use a composite string key, e.g. convert each ID to hex and join them.

  1. Wrong field name in payload size check (tunnel.ts sendResponse)

The code checks ctx.protocolMetadata?.maxPayloadSize but the protocol field is maxResponsePayloadSize. This comparison is always against undefined, so the payload size limit is silently bypassed.

  1. requestToActor never populated (tunnel.ts)

handleRequestStart forwards the message to the actor but never inserts into ctx.requestToActor. The map remains empty, so handleRequestChunk and handleRequestAbort can never route chunks to the correct actor.

  1. Unawaited async in error path (tunnel.ts handleRequestStart)

sendResponse is async but is not awaited in the actor-not-found 503 path. Errors are silently dropped.

MODERATE ISSUES

  1. No error handling in spawned fetch tasks (actor.ts)

Both streaming and non-streaming paths call spawn(async () => ...) without any .catch() or try/catch. If fetch or sendResponse throws, the error is silently swallowed and the client hangs waiting for a response that never arrives.

  1. Possible .bare schema violation (v1.bare)

CLAUDE.md says not to modify an existing published *.bare protocol version. This PR adds maxResponsePayloadSize: u64 to ProtocolMetadata in v1.bare. If this schema is already deployed, this is a breaking wire-format change and needs a new versioned schema instead.

  1. name field removed from ToRivetInit (connection.ts)

name: config.poolName was silently dropped from the ToRivetInit message. If the engine still reads this field for pool identification, this is a silent breakage that should be documented.

MINOR ISSUES

  1. clientMessageIndex declared but never used - actor.ts PendingRequest interface: field initialized to 0, never read or incremented.

  2. SIGINT handler logs wrong signal name (test-envoy/src/index.ts) - logs "received SIGTERM" inside the SIGINT handler.

  3. Left-over local dev path in package.json - antiox was previously "link:/home/nathan/antiox", unbuildable outside that machine. Fixed to 0.1.4.

  4. Missing newline at EOF in tunnel.ts and both new package.json files.

  5. Exhaustiveness check passes wrong argument (tunnel.ts) - unreachable(msg.messageKind.tag) passes a string; pass msg.messageKind (the discriminated union) for compile-time exhaustiveness.

  6. Formatting inconsistency in ToActor union (actor.ts) - new union members mix , and ; as property separators.

POSITIVE CHANGES

  • Liveness check fix in actor2 workflow: returning { expired, now } and updating last_liveness_check_ts = res.now correctly fixes a bug where the timestamp was never updated, causing redundant liveness checks.
  • tokio::try_join! for gateway startup: cleaner concurrent startup.
  • WebSocket open-event await: eliminates a race condition on connect.
  • startEnvoy now returns EnvoyHandle and resolves only after ToEnvoyInit is received - good API design.
  • wsSend refactored to connection.ts: removing the duplicate implementation and passing ctx.shared explicitly is cleaner.

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.

1 participant