Skip to content

fix(realtime): stop passing the library's 1002 upstream as the client's close code - #1340

Merged
jarvis9443 merged 2 commits into
mainfrom
fix/realtime-client-invalid-close
Oct 21, 2026
Merged

jarvis9443 merged 2 commits into
mainfrom
fix/realtime-client-invalid-close

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

Follow-up to #1339, same bug class in the other direction. When a client closes /v1/realtime with a code that may not be sent (1004, 2999, ...), axum's tungstenite replaces the frame with its own (1002, "Protocol violation") and drops the original code, and the relay forwarded that to the upstream as if the client had sent 1002.

That exact frame now reaches the upstream as 1011 with an empty reason, matching what #1339 does for upstream closes. Any other legal client code, 1002 with a different reason included, is still forwarded as received. Nothing changes for the client or the access log.

Test: realtime-close-e2e gets a case where the client writes a masked Close(1004) by hand (ws refuses to send it) and the mock upstream must observe 1011. It sees 1002 on main.

🤖 Generated with Claude Code

…'s close code

axum's tungstenite replaces a client Close whose code may not be sent
(1004, 1016-2999, ...) with its own (1002, "Protocol violation"), and the
relay forwarded that to the upstream as if the client had sent 1002.
Apply the rule #1339 introduced for the other direction: that exact frame
reaches the upstream as 1011; any other legal client code is still
forwarded as received.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 9 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 4a3c0c75-0068-4c6e-8858-a010bc32d3e7
📥 Commits

Reviewing files that changed from the base of the PR and between 889a093 and 934cb07.

📒 Files selected for processing: 2
  • crates/aisix-proxy/src/realtime.rs
  • tests/e2e/src/cases/realtime-close-e2e.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 merged commit c997688 into main Oct 21, 2026
19 checks passed
@jarvis9443
jarvis9443 deleted the fix/realtime-client-invalid-close branch October 21, 2026 12:38
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