Skip to content

fix: flip parentFieldRetried inside probe IIFE before resolveProbe() (re-lands #1456) - #1514

Merged
nwparker merged 1 commit into
mainfrom
fix/parentfield-retried-race-1456
May 6, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/parentfield-retried-race-1456

Conversation

@nwparker

@nwparker nwparker commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Re-lands the fix originally proposed in #1456, on current main.

The race itself is real: in fetchAllItems(), sibling callers awaiting parentFieldProbeInFlight.get(scopeKey) are woken by resolveProbe() inside the probe IIFE's finally block, but parentFieldRetriedByOwner.add(scopeKey) was set after await probePromise in the outer block. That gap lets siblings observe parentFieldProbeInFlight cleared and parentFieldRetriedByOwner not-yet-set → each issues its own duplicate with-parent probe.

This patch flips parentFieldRetriedByOwner.add(scopeKey) inside the probe IIFE, before resolveProbe(), eliminating the gap.

Why a new PR instead of merging #1456

#1456 branched off pre-#1465 main. Its effective diff against current main would have reverted #1465's owner-keyed parent-field caches (parentFieldRetriedByOwner Set, parentFieldWarningLoggedByOwner Set, parentFieldProbeInFlight Map, ownerScopeKey() helper) back to the original global flags — a silent regression hidden inside ~700 lines of unrelated formatting noise. GitHub flagged it mergeStateStatus: DIRTY.

Closing #1456; this PR carries forward only the actual race fix.

Verification

  • pnpm typecheck:node — clean
  • pnpm lint — clean (7 pre-existing warnings unchanged)
  • npx vitest run src/main/github/project-view.test.ts — 22/22 pass

Diff

@@ probePromise = (async () => {
   try {
-    return await fetchItemsPageWithRaw({...})
+    const result = await fetchItemsPageWithRaw({...})
+    // Why: flip parentFieldRetriedByOwner BEFORE resolveProbe()/clearing
+    // parentFieldProbeInFlight so siblings that awoke on `inFlight.catch()`
+    // observe the updated flag.
+    if (!result.ok && errorsIndicateParentField(result.rawErrors, result.stderr)) {
+      parentFieldRetriedByOwner.add(scopeKey)
+    }
+    return result
   } finally {
     resolveProbe()
     parentFieldProbeInFlight.delete(scopeKey)
   }
 })()

Closes #1456

Closes the race where siblings awaiting parentFieldProbeInFlight wake
between resolveProbe() and the deferred parentFieldRetriedByOwner.add()
in the outer block, see parentFieldProbeInFlight=null +
parentFieldRetriedByOwner without scopeKey, and issue duplicate
with-parent probes.

Originally raised in #1456, but that PR branched off pre-#1465 main and
its diff against current main reverted #1465's owner-keyed parent-field
caches back to global flags. This re-applies the fix on current main.

Refs #1456
@nwparker
nwparker merged commit a75e706 into main May 6, 2026
3 checks passed
@nwparker
nwparker deleted the fix/parentfield-retried-race-1456 branch May 6, 2026 22:38
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#1514)

Closes the race where siblings awaiting parentFieldProbeInFlight wake
between resolveProbe() and the deferred parentFieldRetriedByOwner.add()
in the outer block, see parentFieldProbeInFlight=null +
parentFieldRetriedByOwner without scopeKey, and issue duplicate
with-parent probes.

Originally raised in stablyai#1456, but that PR branched off pre-stablyai#1465 main and
its diff against current main reverted stablyai#1465's owner-keyed parent-field
caches back to global flags. This re-applies the fix on current main.

Refs stablyai#1456

Co-authored-by: nwparker <[email protected]>
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