Skip to content

Conversation

@twsouthwick
Copy link
Member

@twsouthwick twsouthwick commented Jun 28, 2023

These tests relied on some timing for file writes and static property access. This causes a race condition where the change monitor is disposed at some point internally, but at the same time the test tries to dispose it. This causes the list of change monitors to be enumerated/modified at the same time leading to a crash. The following are fixes/mitigations:

  • Used a TaskCompletionSource for better management of timing in the test to ensure we wait the right amount of time
  • Added a lock in the dispose method to guard against reentrancy

This also changed the IHttpRuntime access to go through HttpContext.Current instead of a static property. While not necessary for the current bug, it has been the source of other issues where a test will set the static property at the same time another test is using it. Switching to HttpContext.Current will prevent similar issues as the IHttpRuntime will be request/test local.

These tests relied on some timing for file writes and static property access. This replaces that with a TaskCompletionSource as well as uses the HttpContext.Current for the static access so it can't have race conditions.
Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of very small nitpicks but looks great otherwise. Thanks for the fast turnaround @twsouthwick, hopefully we can get this in sooner rather than later so that we can push the packages to NuGet.

@twsouthwick twsouthwick merged commit 1f4826a into main Jun 29, 2023
@twsouthwick twsouthwick deleted the http-runtime-tests branch June 29, 2023 00:59
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.

3 participants