Skip to content

fix(upload): ignore duplicate closed-pipe writer errors - #1391

Open
rbtr wants to merge 1 commit into
simulot:mainfrom
rbtr:bugfix/duplicate-closed-pipe
Open

rbtr wants to merge 1 commit into
simulot:mainfrom
rbtr:bugfix/duplicate-closed-pipe

Conversation

@rbtr

@rbtr rbtr commented Jul 11, 2026

Copy link
Copy Markdown

Immich can close the multipart request body early when the x-immich-checksum header identifies an existing asset. PR #854 intended to tolerate the resulting io.ErrClosedPipe, but uploadAsset checked the stale error from the earlier file Stat call before receiving the request and multipart-writer errors. Repeated or resumed uploads therefore aborted when they encountered assets already present on the server.

Collect the request and multipart-writer errors before evaluating them. Suppress io.ErrClosedPipe only when Immich returned duplicate status, while preserving unrelated errors and closed-pipe failures for non-duplicate responses. Add regression coverage for direct and wrapped request errors, writer errors, mixed errors, and non-duplicate uploads.

Fixes: #1271

Immich can close the multipart request body early when the x-immich-checksum header identifies an existing asset. PR simulot#854 intended to tolerate the resulting io.ErrClosedPipe, but uploadAsset checked the stale error from the earlier file Stat call before receiving the request and multipart-writer errors. Repeated or resumed uploads therefore aborted when they encountered assets already present on the server.

Collect the request and multipart-writer errors before evaluating them. Suppress io.ErrClosedPipe only when Immich returned duplicate status, while preserving unrelated errors and closed-pipe failures for non-duplicate responses. Add regression coverage for direct and wrapped request errors, writer errors, mixed errors, and non-duplicate uploads.

Fixes: simulot#1271

Signed-off-by: Evan Baker <2940321+rbtr@users.noreply.github.com>
@rbtr
rbtr requested a review from simulot as a code owner July 11, 2026 17:39
@arturict

Copy link
Copy Markdown

Could you include a quick negative test case demonstrating closed-pipe writer error dedupe behavior under retry conditions?

@lgrn

lgrn commented Jul 26, 2026

Copy link
Copy Markdown

just wanted to chime in and say that building from this branch fixed an issue for me where this command (ish):

./immich-go upload from-google-photos --log-level WARN \
--include-unmatched --exclude-extensions .mp4,.mov \
-k redacted \
-s https://url \
takeout___.zip

would result in the import job crashing with a bunch of read/write on closed pipe with hundreds of assets left in pending, it now seems to run through it without issue.

@rbtr

rbtr commented Jul 27, 2026

Copy link
Copy Markdown
Author

happy it helped you @lgrn ❤️ that is exactly how it was failing for me.
@arturict i have been busy elsewhere, coming back to this - do you want a pre-fix failing test? i can rebuild the PR TDD-style with that failing test and then the fix on top?

@hmnd

hmnd commented Aug 10, 2026

Copy link
Copy Markdown

Just ran into this bug myself and almost put up my own pr before finding this one! Would be great to get this one merged.

This branch has not been deployed

No deployments
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.

constantly failing on the reupload/metadata update with io: read/write on closed pipe during the later stages of file

4 participants