Skip to content

Add opt-in game message delivery confirmations - #375

Merged
justinfernald merged 2 commits into
masterfrom
jo/message-delivery-confirmation
Jul 28, 2026
Merged

Add opt-in game message delivery confirmations#375
justinfernald merged 2 commits into
masterfrom
jo/message-delivery-confirmation

Conversation

@justinfernald

@justinfernald justinfernald commented Jul 28, 2026

Copy link
Copy Markdown
Member

Closes #295

What changed

  • add an optional delivery-confirmation argument to controller, host, broadcast, and smart-player game-message APIs
  • preserve existing fire-and-forget calls and raw payloads by default
  • resolve confirmed sends only after the receiving game iframe acknowledges them
  • reject with typed timeout, unavailable-recipient, or communicator-destroyed errors
  • wait for every connected recipient during confirmed broadcasts and authenticate host-side acknowledgements against the target player
  • document the compatibility requirement and reserved protocol field
  • use the repository's established Promise.withResolvers test shim so the new communicator tests run on the Node 20 CI target

Verification

  • npx -y node@20.10.0 ./node_modules/vitest/vitest.mjs run --coverage — passed (32 tests) in the exact hosted Node version
  • corepack yarn vitest run test/src/message-delivery.test.ts test/src/player-models.test.ts — passed (14 tests)
  • corepack yarn vitest run — passed (32 tests)
  • corepack yarn build — passed, including declaration generation
  • corepack yarn lint:check — passed
  • changed-file Prettier check — passed
  • git diff --check — passed
  • targeted source-and-test TypeScript project — passed
  • corepack yarn type-check — repository baseline failure: TS6305 for vite.config.d.ts because the root config includes vite.config.ts while referencing tsconfig.node.json; unrelated to this patch

Demo

Non-visual library change; screenshots and screencasts are not applicable. Reproduce with corepack yarn vitest run test/src/message-delivery.test.ts, which exercises controller-to-host, host-to-controller, multi-recipient broadcast, timeout, disconnect, spoofed acknowledgement, and cleanup behavior.

@justinfernald
justinfernald merged commit 69fec97 into master Jul 28, 2026
2 checks passed
@justinfernald
justinfernald deleted the jo/message-delivery-confirmation branch July 28, 2026 04:08

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aca0e7ecd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

options,
);
const { messageId } = envelope.__tpgCoreDelivery;
const connectionDisposer = player.addConnectionListener((hasConnection) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove settled delivery disposers from the player

Each confirmed targeted send calls player.addConnectionListener, which appends its MobX reaction disposer to SmartPlayerModel.destructors. The delivery cleanup invokes that disposer but never removes it from the array, so repeated confirmed sends or broadcasts permanently retain one stopped reaction function per recipient per message. Long-running games using confirmations regularly will therefore accumulate unbounded per-player memory; use a listener path that does not register in destructors, or remove the disposer from that collection when delivery settles.

Useful? React with 👍 / 👎.

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.

Add message confirmation

1 participant