Skip to content

Follow the spec rules for message fragmentation - #202

Merged
maximmaxim345 merged 2 commits into
mainfrom
fix/fragment-messages-per-spec
Oct 26, 2026
Merged

maximmaxim345 merged 2 commits into
mainfrom
fix/fragment-messages-per-spec

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

Fragmented messages from a server following the spec were dropped, since the client only understood the old ID 2/3 fragment format. Sending a message larger than one Noise transport message threw instead of being fragmented.

Fragments now use ID 1 with a flags byte in both directions, and a malformed fragment sequence closes the connection. IDs 2 and 3 are now ignored like any other unknown binary ID.

Breaking changes:

  • A server that still sends the old ID 2/3 fragments now loses any message too large for one transport message.

Related issue or spec PR (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes the public API or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

Fragmented messages from a spec-compliant server were dropped, and a
control message over one Noise transport message threw instead of being
sent.
@maximmaxim345
maximmaxim345 requested a balanced review from Copilot October 26, 2026 14:16
@github-actions github-actions Bot added the breaking-change Changes the public API or the protocol in a way that is not backwards compatible label Oct 26, 2026

Copilot AI 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.

🟢 Approval recommended

Static review supports the framing and size calculations, with no unresolved blocking findings; tests were not executed.

No open issues 🎉

What changed in this PR

Updates Sendspin transport fragmentation to match the specification, allowing large messages to be received and sent using ID 1 with fragment flags. Legacy ID 2/3 fragments are no longer recognized.

Changes:

  • Adds flag-based fragment reassembly and closes connections on malformed sequences.
  • Splits oversized outbound control messages into transport-sized fragments.
  • Updates tests for the new format, invalid sequences, and outbound fragmentation.
File Description
tests/​unit/​transport.test.ts Updates inbound fragment fixtures to ID 1 with flags.
tests/​unit/​transport-framing.test.ts Covers malformed sequences, empty payloads, and outbound fragmentation.
src/​core/​transport.ts Implements flag-based framing, validation, and outbound splitting.

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit bf52042 into main Oct 26, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/fragment-messages-per-spec branch October 26, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Changes the public API or the protocol in a way that is not backwards compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants