Skip to content

fix(bb-realtime): align local message envelopes with AWS runtime - #279

Open
ikenyal wants to merge 3 commits into
aws-devtools-labs:mainfrom
ikenyal:fix/realtime-wire-key-consistency
Open

fix(bb-realtime): align local message envelopes with AWS runtime#279
ikenyal wants to merge 3 commits into
aws-devtools-labs:mainfrom
ikenyal:fix/realtime-wire-key-consistency

Conversation

@ikenyal

@ikenyal ikenyal commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Issue #, if available: Fixes #253

The local Realtime WebSocket server emitted published messages as { type, channel, payload }, while the AWS runtime emits { type, channel, data }. This made local development expose a different wire envelope to direct and native clients.

Changes

  • Emit the AWS-compatible data key from both local publish paths.
  • Update mock middleware delivery to read data.
  • Add regression coverage for EventEmitter broadcasts and client-originated publishes.
  • Remove the documented mock/AWS envelope difference in packages/bb-realtime/DESIGN.md.
  • Add a patch changeset for @aws-blocks/bb-realtime.

Validation

  • npm run build
  • npm run lint
  • npm run lint:deps
  • npm test
  • npm run test:e2e:local
  • npm run build --workspace=@aws-blocks/bb-realtime && npm test --workspace=@aws-blocks/bb-realtime (72 tests)
  • Deployed the comprehensive sandbox app: the Realtime suite passed (7/7). The complete sandbox suite could not finish because the separate test account lacks an SES-verified noreply@example.com sender and the Bedrock agent did not respond before its timeout; the stack was destroyed afterward.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ikenyal
ikenyal requested a review from a team as a code owner July 29, 2026 06:30
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d38790e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-blocks/bb-realtime Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Simone319 Simone319 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for making the fix.

One minor comment:
Shall we update the payload from the root here as well? So that we don't need multiple payload -> data translation which is easy to miss.

@ikenyal

ikenyal commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that is a good point. I updated the local broadcast bus to emit { channel, data } directly from Realtime.publish() and updated ws-server to consume that shape, removing the intermediate payload to data translation.

I also updated the direct broadcast and reconnect regression tests. The client-originated WebSocket publish request remains { action, channel, payload } because it is a separate existing input protocol; emitted message envelopes remain { type, channel, data }.

Validated with:

  • npm run build
  • npm run lint
  • npm run lint:deps
  • npm test
  • npm run test:e2e:local

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.

bb-realtime: mock/dev-server and AWS runtime disagree on message wire key (payload vs data)

3 participants