Skip to content

fix: ignore cancelled promise settlements after effect reconnection - #5823

Open
Eotel wants to merge 1 commit into
statelyai:mainfrom
Eotel:codex/fix-cancelled-promise-settlement
Open

Eotel wants to merge 1 commit into
statelyai:mainfrom
Eotel:codex/fix-cancelled-promise-settlement

Conversation

@Eotel

@Eotel Eotel commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

React Strict Mode can reconnect a promise actor before its aborted invocation settles. That invocation can replace the current result or fail a newly started request.

 onPromiseSettled
-  if actor is inactive: ignore
+  if this invocation was aborted or actor is inactive: ignore
   deliver the current result

Evidence

  • Before: the new resolve/reject regressions fail in Strict Mode: 2 failed | 2 passed | 36 skipped.
    After: useActorRef.test.tsx: 40 passed.
  • Full workspace tests: 2434 passed | 16 skipped | 1 todo.
  • pnpm lint, pnpm format:check, and pnpm typecheck pass.

Merge Danger

Door: two-way

Blast Radius: core

Only invocations whose abort signal has fired are ignored. Active promise results retain the existing behavior.

Session: /root


Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Cancelled promise operations no longer update the displayed result after React Strict Mode reconnects effects. Loading state now reflects the current operation rather than an aborted request.
  • Tests
    • Added regression coverage for cancelled operations that resolve or reject.

@changeset-bot

changeset-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c7bad48

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

This PR includes changesets to release 1 package
Name Type
xstate 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T04:21:53.596793Z
We couldn’t complete this review. Comment @codex review to try again.
c7bad48 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fc72fc1-0b2d-4189-b94f-2547d7dbf521
Commits

Reviewing files that changed from the base of the PR and between 8f25b68 and c7bad48.

Files selected for processing: 3
  • .changeset/silly-eagles-try.md
  • packages/core/src/actors/promise.ts
  • packages/xstate-react/test/useActorRef.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Promise actors now ignore resolutions and rejections after their abort signal is set. A React regression test checks that the current invocation’s result is displayed after effect reconnection.

Changes: Promise abort handling

Layer / File(s) Summary
Ignore settlements after abort
packages/core/src/actors/promise.ts, packages/xstate-react/test/useActorRef.test.tsx, .changeset/silly-eagles-try.md
Resolution and rejection handlers skip relaying events when the abort signal is set. The regression test covers abort handlers that resolve or reject and checks that the displayed result is current. The changeset records the patch.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: davidkpiano

Merge Risk: Minimal · up to c7bad

Cancelled promise results are ignored while the current invocation can complete. No identified issue prevents merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: ignoring cancelled promise settlements after React effect reconnection.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Eotel added a commit to shiftone-ai/caption-relay that referenced this pull request Oct 25, 2026
Add home-based registration and reconnection, isolated room captions and AI
context, and confirmation for reset and leaving unsaved work. Keep settings
across restarts, store private editing links with 0600 permissions, and reject
stale tabs and retired utterance replays. Preserve hidden state on reconnect
and start only the configured input.

Integrate with main at de2898a. Retain the current AI model selection,
contextual correction and inspector controls. Apply the cancellation fix
submitted in statelyai/xstate#5823 during locked dependency installation.

Validation: bash scripts/check.sh passes (141 frontend tests, 194 backend
tests, generated API agreement, type checks and build). A clean npm ci applies
the dependency patch and passes its StrictMode regression. Real browser tests
use a dedicated local API and synthetic captions for registration, reconnect,
reset/cancel, stale saves, restart persistence, and desktop/mobile layouts.
The UI review was an independent pass in the same conversation because separate
sessions are unavailable. Final disposition: ship. Usage docs and screenshots
are updated; the completed temporary implementation plan is removed.

No live UD Talk, microphone or LLM connection was used for this change.
The upstream fix passes its workspace tests and remote checks. Upstream GitHub
permissions prevent assigning its PR to Eotel. No implementation work remains
on this isolated branch; integration into the active checkout is separate.

This branch has not been deployed

No deployments
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