OData / OData/AspNetCoreOData

Parallel requests cause responses to get mixed

Open
#57 10 comments 10 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since Aug 31, 2021.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

When 2 requests are performed at the same time, there is a possibility that one's response will contain 2 concatenated JSON strings

{"@odata.context":"http://localhost:64149/odata/$metadata#Books(Author())","value":[]}{"@odata.context":"http://localhost:64149/odata/$metadata#Books(Author())","value":[]}

and the other will crash with System.ObjectDisposedException: Cannot write to the response body, the response has completed. Object name: 'HttpResponseStream' or System.InvalidOperationException: Reading is already in progress..

I've created a minimal repo you can clone and try to reproduce the issue. It uses efcore with in memory database but the same happens with SQL Server. I've also added a readme for the few steps required to reproduce the issue.

Tried the same with an Api Controller and had no issues.
NET 5, Microsoft.AspNetCore.OData 8.0.0-preview3, Visual Studio 2019 16.8.3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.