Skip to content

Fix offload task intermittently not running in MSTest environment.#567

Open
kalbert312 wants to merge 1 commit intoaspnet:mainfrom
kalbert312:kylea/fix-offload-task
Open

Fix offload task intermittently not running in MSTest environment.#567
kalbert312 wants to merge 1 commit intoaspnet:mainfrom
kalbert312:kylea/fix-offload-task

Conversation

@kalbert312
Copy link
Copy Markdown

Fixes #566

@kalbert312
Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="Microsoft"

state.Dispose();
}
});
}, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the Task.Factory call inside RequestState.CompleteResponse() also be updated to use TaskScheduler.Default?

Copy link
Copy Markdown
Author

@kalbert312 kalbert312 Mar 27, 2026

Choose a reason for hiding this comment

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

I believe the issue is specific to StartNew with async callbacks, but not certain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Did some test debug runs on the minimal repo example. Could not get the non-async delegate usage of StartNew to not run. 😕

@kalbert312
Copy link
Copy Markdown
Author

kalbert312 commented Mar 30, 2026

I noticed this only seems to happen with JetBrains Rider debugger. I cannot seem to reproduce this yet in VS2026. It is a very confusing issue. I opened an issue on their board: https://youtrack.jetbrains.com/issue/RIDER-134081/Debugging-MSTest-4-.NET-Framework-4.7.2-test-hangs-works-in-VS2022

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.

Microsoft.Owin.Testing.OwinClientHandler: Sometimes the offload task never runs, resulting in hanging tests.

2 participants