Skip to content

fix(FiberHandle): prevent clear() from wiping newer fiber during interrupt wait#6214

Open
lihan3238 wants to merge 1 commit intoEffect-TS:mainfrom
lihan3238:fix-5906
Open

fix(FiberHandle): prevent clear() from wiping newer fiber during interrupt wait#6214
lihan3238 wants to merge 1 commit intoEffect-TS:mainfrom
lihan3238:fix-5906

Conversation

@lihan3238
Copy link
Copy Markdown

Fixes a race condition in FiberHandle.clear() where an unconditional state.fiber = undefined could wipe out a newer fiber reference stored by a concurrent run()/set() call during the interrupt wait window.

Save a reference to the target fiber before interrupting, then only clear if state.fiber === target.

Fixes #5906

Test plan

  • Existing FiberHandle tests pass
  • Issue author provided reproduction script that demonstrates the race

…rrupt wait

Save a reference to the target fiber before interrupting, then only
clear if the stored fiber still matches the target. This prevents a
race where another fiber calls run()/set() during the interrupt wait
window and gets its reference unconditionally wiped.

Fixes Effect-TS#5906
@lihan3238 lihan3238 requested a review from mikearnaldi as a code owner May 5, 2026 17:49
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog May 5, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: 034f1d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

FiberHandle.clear looks racy ?

1 participant