Skip to content

fix: Promise.any race condition in validator script check (#1007)#1010

Merged
Wirasm merged 2 commits into
devfrom
fix/issue-1007-promise-any-race
Apr 9, 2026
Merged

fix: Promise.any race condition in validator script check (#1007)#1010
Wirasm merged 2 commits into
devfrom
fix/issue-1007-promise-any-race

Conversation

@Wirasm

@Wirasm Wirasm commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • validateWorkflowResources used Promise.any to check if a named script file exists, but fileExists always fulfills (never rejects), so Promise.any returned the first resolved value regardless of truthiness — a race condition that flaked on Windows CI
  • Replaced with Promise.all + .some(Boolean) which is deterministic

Changes

File Change
packages/workflows/src/validator.ts Replace Promise.any with Promise.all + .some()

Testing

  • Type check passes
  • All 35 validator tests pass
  • Full bun run validate passes (0 failures across all packages)
  • Lint + format clean

Validation

bun run validate

Fixes #1007

Summary by CodeRabbit

  • Documentation

    • Added investigation documentation outlining workflow operation improvements, including approval gate enhancements, artifact directory handling updates, and CLI conversation continuity improvements.
  • Refactor

    • Improved internal script validation logic for better resource checking.

Wirasm added 2 commits April 9, 2026 19:36
…1007)

Promise.any resolves with the first fulfilled promise regardless of value.
Since fileExists always fulfills (never rejects), Promise.any could return
false even when a later extension check would return true — a race condition
that flaked on Windows CI.

Fixes #1007
@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5628d4b-01a1-4347-b6b5-0e196014b1ff

📥 Commits

Reviewing files that changed from the base of the PR and between 0d1ff41 and 9e868dd.

📒 Files selected for processing (2)
  • .claude/PRPs/issues/issue-1001-1002-1003.md
  • packages/workflows/src/validator.ts

📝 Walkthrough

Walkthrough

The PR introduces comprehensive documentation describing bug root causes and fixes and corrects a timing-dependent test flake in the workflow validator by replacing Promise.any() with Promise.all() for checking script file existence across multiple extensions.

Changes

Cohort / File(s) Summary
Documentation
.claude/PRPs/issues/issue-1001-1002-1003.md
New investigation document detailing three workflow bug root causes: approval gate metadata capture, artifact directory access, and CLI conversation ID propagation; includes step-by-step fix implementation, test commands, and edge-case handling guidance.
Bug Fix
packages/workflows/src/validator.ts
Replaced Promise.any(...).catch() race condition with Promise.all(...) aggregation followed by .some(Boolean) to reliably check if named script files exist across multiple extensions, eliminating Windows CI timing flake.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A race once stirred on Windows bright,
Where promises would flip the fight—
Now all resolve before we deem,
No more a timely, flickering dream! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1007-promise-any-race

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 and usage tips.

@Wirasm

Wirasm commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review

Verdict: PASS — no issues found.

The root cause diagnosis is correct: fileExists always fulfills (catches access() rejection internally, returns false), so Promise.any resolves with the first settled value regardless of truthiness. On Windows CI where .js can settle before .ts, this returns false even when the .ts file exists.

The fix (Promise.all + .some(Boolean)) is minimal, correct, and deterministic. The removed .catch(() => false) was dead code since fileExists never rejects. Single-extension paths (uv runtime) are unaffected.

No edge cases missed, no regressions introduced.

@Wirasm Wirasm merged commit 2994d56 into dev Apr 9, 2026
2 of 4 checks passed
@Wirasm Wirasm deleted the fix/issue-1007-promise-any-race branch April 9, 2026 16:42
leex279 pushed a commit that referenced this pull request Apr 9, 2026
)

* Investigate issues #1001, #1002, #1003: interactive-prd workflow bugs

* fix: replace Promise.any with Promise.all in validator script check (#1007)

Promise.any resolves with the first fulfilled promise regardless of value.
Since fileExists always fulfills (never rejects), Promise.any could return
false even when a later extension check would return true — a race condition
that flaked on Windows CI.

Fixes #1007
imagicrafter pushed a commit to imagicrafter/archon that referenced this pull request Apr 9, 2026
…fix-dag-bash-validation

Fix DAG validation emitting wrong error for empty bash/prompt nodes
@Wirasm Wirasm mentioned this pull request Apr 10, 2026
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
…fix-dag-bash-validation

Fix DAG validation emitting wrong error for empty bash/prompt nodes
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
) (coleam00#1010)

* Investigate issues coleam00#1001, coleam00#1002, coleam00#1003: interactive-prd workflow bugs

* fix: replace Promise.any with Promise.all in validator script check (coleam00#1007)

Promise.any resolves with the first fulfilled promise regardless of value.
Since fileExists always fulfills (never rejects), Promise.any could return
false even when a later extension check would return true — a race condition
that flaked on Windows CI.

Fixes coleam00#1007
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…fix-dag-bash-validation

Fix DAG validation emitting wrong error for empty bash/prompt nodes
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
) (coleam00#1010)

* Investigate issues coleam00#1001, coleam00#1002, coleam00#1003: interactive-prd workflow bugs

* fix: replace Promise.any with Promise.all in validator script check (coleam00#1007)

Promise.any resolves with the first fulfilled promise regardless of value.
Since fileExists always fulfills (never rejects), Promise.any could return
false even when a later extension check would return true — a race condition
that flaked on Windows CI.

Fixes coleam00#1007
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.

fix: Promise.any in validator script check is timing-dependent (Windows CI flake)

1 participant