AsyncExtensions icon indicating copy to clipboard operation
AsyncExtensions copied to clipboard

Fix race condition in `AsyncCurrentValueSubject`

Open wfltaylor opened this issue 1 year ago • 1 comments

Description

If a value is sent to the subject while handleNewConsumer() is running, it is possible for the new consumer to miss this value. This is because the currentValue is read before the state is updated with the channel. This is addressed by setting the current value at the same point that the channel is added to the state.

Checklist

  • [x] this PR is based on the main branch and is up-to-date, if not please rebase your branch on the top of main
  • [x] the commits inside this PR have explicit commit messages
  • [ ] unit tests cover the new feature or the bug fix
  • [x] the feature is documented in the README.md if it makes sense
  • [ ] the CHANGELOG is up-to-date

wfltaylor avatar Jan 31 '24 11:01 wfltaylor

Hello! I encountered a similar problem. This fix seems to help me. Is there a plan to merge? Thanks anyway!

DanDolog avatar Jun 02 '25 20:06 DanDolog