WrappingStream closes the base stream even when disposeBaseStream is false
@JamBalaya56562 is already working on this.
Since Oct 24, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
Research direction
Start by reading WrappingStream.Close(), Dispose(), and DisposeAsync() to trace how DisposeBaseStream affects the base stream; the issue names these entry points and includes a reproduction with TimeoutObservingStream. Check the behavior for both disposeBaseStream values across synchronous and asynchronous disposal. Done when the base stream stays open for false and is disposed correctly for true.
Written by the indexing model from the issue text.
Description
Problem
WrappingStream.Close() always calls BaseStream.Close(), without looking at DisposeBaseStream. Stream.Dispose() calls Close(), and WrappingStream.DisposeAsync() ends with base.DisposeAsync(), which also calls Close(). So:
- with
disposeBaseStream: false, the base stream is closed byDispose(),Close(),DisposeAsync(),usingandawait usingalike; - with
disposeBaseStream: true, the base stream is disposed two or three times.
Close() has closed the base stream since the first version; DisposeBaseStream was added later (eb35fdf), so false has never taken effect. The current main (21240f3, v1.0.5) has the same code.
Reproduction
using Duplicati.StreamUtil;
var baseStream = new MemoryStream();
using (new TimeoutObservingStream(baseStream, disposeBaseStream: false)) { }
Console.WriteLine(baseStream.CanRead); // False, expected True
Counting the calls on the base stream (Duplicati.StreamUtil 1.0.5):
disposeBaseStream=false using -> base: Close;Dispose(True)
disposeBaseStream=false await using -> base: Close;Dispose(True)
disposeBaseStream=false Close() -> base: Close;Dispose(True)
disposeBaseStream=true using -> base: Close;Dispose(True);Close;Dispose(True)
disposeBaseStream=true await using -> base: DisposeAsync;Close;Dispose(True);Close;Dispose(True);Close;Dispose(True)
Impact on Duplicati
Most Duplicati backends wrap the caller's stream with ObserveReadTimeout(..., false) / ObserveWriteTimeout(..., false) in a using statement, expecting the caller's stream to stay open. It is closed instead. The regular backup path is shielded (the download chain has a ShaderStream(..., keepBaseOpen: true), and an upload reopens the file on every attempt), but the remote synchronization tool and multiple destinations (LightWeightBackendManager) reuse the stream after the call. With a test backend that wraps the caller's stream the way the SSH backend does:
--verify-get-after-putfails (exit code 3)- a failed get or put is retried with the closed stream, so all retries fail ("failed after 3 attempts")
- the rename fallback (
prevent-backend-rename) fails - reading
PositionafterGetAsyncthrowsObjectDisposedException: Cannot access a closed file
duplicati/duplicati#6806 ("Cannot access a closed file" when using multiple destinations) had the same cause; duplicati/duplicati#6809 worked around it by computing the hash before the upload.
- Dominant language
- C#
- Stars
- 0
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Realm667/WolfenDoom#1758 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
AI documentation good first issue help wanted
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
akshit-bansal11/edgepad#106 ·
Maintainers usually reply within 1 day