Skip to content

Guard action handle signal writes against stale submissions - #132

Open
nakasyou wants to merge 1 commit into
mainfrom
devin/1790237732-action-submission-guard
Open

nakasyou wants to merge 1 commit into
mainfrom
devin/1790237732-action-submission-guard

Conversation

@nakasyou

Copy link
Copy Markdown
Member

Summary

When the same action handle is invoked concurrently (double-click, rapid re-invoke), invoke wrote result/error/lastSubmission/pending after awaits with no ordering guard, so an older submission resolving last would overwrite the newer result, and isPending flipped to false as soon as any submission settled.

Fix mirrors the version guard in signal.ts and the router's sequence check:

let latestSubmissionId = 0
const invoke = (input) => {
  const submissionId = ++latestSubmissionId
  ...
  applySubmissionChunk(submissionId, ...)   // each: if (submissionId !== latestSubmissionId) return
  applySubmissionError(submissionId, ...)
  finalizeSubmission(submissionId)          // only clears `pending` if still latest
}

The returned promise / async iterator still resolves with its own value; only the shared handle signals ignore superseded submissions. Single-submission behavior is unchanged.

Adds two unit tests in core/action.test.ts (fail before, pass after).

Link to Devin session: https://app.devin.ai/sessions/0cc06e7eec3c46019e2cca8c422b53de
Open in Devin Desktop: https://app.devin.ai/desktop/session/0cc06e7eec3c46019e2cca8c422b53de?variant=devin
Requested by: @nakasyou

Co-Authored-By: Shotaro Nakamura <syoutarou1103@outlook.jp>
Copilot AI lite review requested due to automatic review settings September 24, 2026 08:15
@nakasyou nakasyou self-assigned this Sep 24, 2026

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Website preview: https://pr-132-eclipsa.xiarenda61.workers.dev

Commit: 49e5fc2

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants