Skip to content

DEV-199 Harden RFQ WebSocket invalid-frame handling#87

Open
cesarenaldi wants to merge 2 commits into
mainfrom
feature/dev-199-harden-rfq-websocket-invalid-frame-handling
Open

DEV-199 Harden RFQ WebSocket invalid-frame handling#87
cesarenaldi wants to merge 2 commits into
mainfrom
feature/dev-199-harden-rfq-websocket-invalid-frame-handling

Conversation

@cesarenaldi
Copy link
Copy Markdown
Collaborator

@cesarenaldi cesarenaldi commented Jun 4, 2026

Summary

  • Ignore unknown RFQ inbound frame types before schema parsing for forward compatibility.
  • Fail and close the RFQ session on malformed known inbound RFQ frames.
  • Add integration coverage for unknown frames during quote/cancel/confirmation waits and malformed known-frame shutdown.

Verification

  • pnpm --filter @polymarket/types build && pnpm --filter @polymarket/bindings build
  • pnpm vitest --project client-integration packages/client/tests/integration/rfq.test.ts (completed; current test fixture skipped 19 tests)
  • pnpm typecheck
  • pnpm lint

Linear: DEV-199


Note

Medium Risk
Changes RFQ session lifecycle on parse errors (session ends vs. staying open); behavior is defensive but affects live quoting/cancel/confirm flows.

Overview
Hardens the RFQ quoter WebSocket so inbound traffic is classified before full parsing. Unknown type values are dropped silently so future server message types do not break existing clients.

Malformed frames that match a known type but fail RfqQuoterInboundMessageSchema now trigger a full session teardown (#fail): pending auth/quote/cancel/confirmation waits are rejected, the event stream ends, and the socket closes—instead of only rejecting pending promises while leaving the session open.

Bindings gain RfqKnownInboundType / RfqKnownInboundMessageSchema shared by all inbound Zod schemas. Integration tests cover unknown frames interleaved with acks and malformed ACK_RFQ_QUOTE shutdown behavior.

Reviewed by Cursor Bugbot for commit 1220e8c. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1220e8c. Configure here.

cause: parsed.error,
});
this.#pending.rejectAll(error);
void this.#fail(error);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frames handled after shutdown

Medium Severity

When a malformed known inbound frame triggers #fail, the session marks #closing, rejects pending work, and ends the event queue, but #handleMessage never checks that state. Additional frames can still arrive and be parsed until the WebSocket finishes closing, so events may be pushed or acks resolved after the session was supposed to be dead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1220e8c. Configure here.

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