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

Reduce NotSupportedException #13194

Open
mikasoukhov opened this issue Jan 25, 2024 · 2 comments
Open

Reduce NotSupportedException #13194

mikasoukhov opened this issue Jan 25, 2024 · 2 comments
Labels
Functionality:SDK The NuGet client packages published to nuget.org help wanted Considered good issues for community contributions. Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug

Comments

@mikasoukhov
Copy link

NuGet Product Used

NuGet SDK

Product Version

sdk

Worked before?

no

Impact

It bothers me. A fix would be nice

Repro Steps & Context

Here is the code line https://github.com/NuGet/NuGet.Client/blob/3f81700cdddeb9d6bda312b90c99be7475bd116b/src/NuGet.Core/NuGet.Packaging/PackageExtraction/StreamExtensions.cs#L101

Why just not to use Stream.CanSeek? To avoid NotSupportedException what is cause drawdown performance on many parallel tasks.

Verbose Logs

No response

@kartheekp-ms kartheekp-ms added Functionality:SDK The NuGet client packages published to nuget.org and removed Triage:Untriaged labels Jan 25, 2024
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Jan 26, 2024

Looking at the https://learn.microsoft.com/dotnet/api/system.io.stream.canseek?view=net-8.0#remarks, it looks like you are proposing following changes, correct?

long? size = null;
try
{
    if (inputStream.CanSeek)
      size = inputStream.Length;
}

// removed catch block because we are relying on `Stream.CanSeek` to set the `size` variable instead of swallowing `NotSupportedException`

if (_isMMapEnabled && size > 0 && size <= MAX_MMAP_SIZE)
{
    MmapCopy(inputStream, fileFullPath, size.Value);
}
else
{
    FileStreamCopy(inputStream, fileFullPath);
}

Given that you already know the fix, feel free to submit the PR by following https://github.com/NuGet/NuGet.Client/blob/dev/CONTRIBUTING.md guidance.

@aortiz-msft aortiz-msft added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. help wanted Considered good issues for community contributions. Pipeline:Icebox labels Feb 12, 2024
@aortiz-msft
Copy link
Contributor

@mikasoukhov - We are open to a PR to address this issue. Something that would help in the issue and PR description would be to understand why you are hitting that code path commonly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org help wanted Considered good issues for community contributions. Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

4 participants