Skip to content

fix: retry transient attachment downloads#1951

Open
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-attachment-download-retry-recovery
Open

fix: retry transient attachment downloads#1951
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-attachment-download-retry-recovery

Conversation

@Ap4sh

@Ap4sh Ap4sh commented Jun 3, 2026

Copy link
Copy Markdown

First time contributor checklist:

Contributor checklist:

  • My commit is in a nice logical chunk with a good commit message
  • My changes are rebased on the latest dev branch
  • Build, lint, and tests pass locally
  • My changes are ready to be shipped to users

Description

Refs #1748

This fixes attachment downloads that can get stuck after a transient network failure

The old retry path treated the third failed attempt as permanent for every non-404 error. That deleted the download job and marked the message attachment as failed, so there was no background recovery path even when the file was still available

This PR keeps normal attachment jobs retryable with capped backoff, while still treating expired 404s and malformed attachment pointers as terminal. It also preserves the attachment metadata needed for future retries and lets failed image attachments render through the generic attachment fallback

Preview jobs keep the existing shorter retry boundary, so this only extends the retry window for normal attachment jobs

Testing

  • Added focused unit coverage for retry decisions, terminal errors, capped retry windows, and metadata preservation
  • Added scheduler-style coverage for AttachmentsDownload.start() covering a later transient failure keeping the job queued while showing the attachment as failed
  • Added model coverage covering error reaching attachment props without exposing retry metadata
  • pnpm exec prettier --check ts/components/conversation/Image.tsx ts/models/message.ts ts/session/utils/AttachmentDownloadRetry.ts ts/session/utils/AttachmentsDownload.ts ts/test/session/unit/models/MessageModel_test.ts ts/test/session/unit/utils/AttachmentDownloadRetry_test.ts ts/test/session/unit/utils/AttachmentsDownload_test.ts
  • pnpm exec eslint ts/components/conversation/Image.tsx ts/models/message.ts ts/session/utils/AttachmentDownloadRetry.ts ts/session/utils/AttachmentsDownload.ts ts/test/session/unit/models/MessageModel_test.ts ts/test/session/unit/utils/AttachmentDownloadRetry_test.ts ts/test/session/unit/utils/AttachmentsDownload_test.ts
  • pnpm exec tsc
  • pnpm test-copy
  • pnpm build-copy
  • pnpm build-compile
  • pnpm exec mocha --no-config --exit --require jsdom-global/register --require app/ts/test/test-utils/setup.js app/ts/test/session/unit/utils/AttachmentDownloadRetry_test.js app/ts/test/session/unit/utils/AttachmentsDownload_test.js app/ts/test/session/unit/models/MessageModel_test.js

Targeted Mocha result: 22 passing

@Ap4sh Ap4sh changed the title Fix transient attachment download retries fix: retry transient attachment downloads Jun 3, 2026
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.

1 participant