Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection was modified; enumeration operation may not execute #42

Closed
grokys opened this issue May 14, 2024 · 0 comments · Fixed by #45
Closed

Collection was modified; enumeration operation may not execute #42

grokys opened this issue May 14, 2024 · 0 comments · Fixed by #45
Assignees
Labels
bug Something isn't working

Comments

@grokys
Copy link
Contributor

grokys commented May 14, 2024

When running tests, after #41 I've started seeing the following exception:

System.InvalidOperationException
  HResult=0x80131509
  Message=Collection was modified; enumeration operation may not execute.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
   at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at FlaUI.WebDriver.Session.EvictUnavailableElements() in D:\projects\FlaUI\FlaUI.WebDriver\src\FlaUI.WebDriver\Session.cs:line 133
   at FlaUI.WebDriver.SessionCleanupService.EvictUnavailableElements(ISessionRepository sessionRepository) in D:\projects\FlaUI\FlaUI.WebDriver\src\FlaUI.WebDriver\SessionCleanupService.cs:line 47
   at FlaUI.WebDriver.SessionCleanupService.DoWork(Object state) in D:\projects\FlaUI\FlaUI.WebDriver\src\FlaUI.WebDriver\SessionCleanupService.cs:line 39
   at System.Threading.TimerQueueTimer.<>c.<.cctor>b__27_0(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

Looks like firing the cleanup on a timer is causing a problem whereby a query is running at the same time, which is adding an item to the dictionary.

@aristotelos aristotelos added the bug Something isn't working label May 14, 2024
@aristotelos aristotelos self-assigned this May 14, 2024
aristotelos added a commit that referenced this issue May 14, 2024
Prevent stale enumerators while evicting unavailable elements or windows. Closes #42.
aristotelos added a commit that referenced this issue May 15, 2024
Prevent stale enumerators and concurrency issues while adding or
victing unavailable elements or windows. Closes #42.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants